ReactOS  r73918
reader.c File Reference
#include "editor.h"
#include "rtf.h"
Include dependency graph for reader.c:

Go to the source code of this file.

Classes

struct  RTFKey
 
struct  tagRTFHashTableEntry
 

Macros

#define RTF_KEY_COUNT   (sizeof(rtfKey) / sizeof(RTFKey))
 

Typedefs

typedef struct RTFKey RTFKey
 
typedef struct tagRTFHashTableEntry RTFHashTableEntry
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (richedit)
 
static int _RTFGetChar (RTF_Info *)
 
static void _RTFGetToken (RTF_Info *)
 
static void _RTFGetToken2 (RTF_Info *)
 
static int GetChar (RTF_Info *)
 
static void ReadFontTbl (RTF_Info *)
 
static void ReadColorTbl (RTF_Info *)
 
static void ReadStyleSheet (RTF_Info *)
 
static void ReadInfoGroup (RTF_Info *)
 
static void ReadPictGroup (RTF_Info *)
 
static void ReadObjGroup (RTF_Info *)
 
static void Lookup (RTF_Info *, char *)
 
static int Hash (const char *)
 
static void CharAttr (RTF_Info *info)
 
static void CharSet (RTF_Info *info)
 
static void DocAttr (RTF_Info *info)
 
static void RTFFlushCPOutputBuffer (RTF_Info *info)
 
static void RTFPutCodePageChar (RTF_Info *info, int c)
 
static charRTFStrSave (const char *s)
 
void RTFSetEditStream (RTF_Info *info, ME_InStream *stream)
 
static void RTFDestroyAttrs (RTF_Info *info)
 
void RTFDestroy (RTF_Info *info)
 
static void RTFSetClassCallback (RTF_Info *info, int class, RTFFuncPtr callback)
 
static RTFFuncPtr RTFGetClassCallback (const RTF_Info *info, int class)
 
void RTFInit (RTF_Info *info)
 
void RTFSetDestinationCallback (RTF_Info *info, int dest, RTFFuncPtr callback)
 
static RTFFuncPtr RTFGetDestinationCallback (const RTF_Info *info, int dest)
 
void RTFRead (RTF_Info *info)
 
void RTFRouteToken (RTF_Info *info)
 
void RTFSkipGroup (RTF_Info *info)
 
void RTFReadGroup (RTF_Info *info)
 
void RTFSetReadHook (RTF_Info *info, RTFFuncPtr f)
 
static RTFFuncPtr RTFGetReadHook (const RTF_Info *info)
 
int RTFGetToken (RTF_Info *info)
 
static void RTFUngetToken (RTF_Info *info)
 
int RTFCharSetToCodePage (RTF_Info *info, int charset)
 
RTFFontRTFGetFont (const RTF_Info *info, int num)
 
RTFColorRTFGetColor (const RTF_Info *info, int num)
 
void LookupInit (void)
 
void LookupCleanup (void)
 
int RTFCheckCM (const RTF_Info *info, int class, int major)
 
int RTFCheckCMM (const RTF_Info *info, int class, int major, int minor)
 
int RTFCheckMM (const RTF_Info *info, int major, int minor)
 
int RTFCharToHex (char c)
 
static void TextClass (RTF_Info *info)
 
static void ControlClass (RTF_Info *info)
 
static void DefFont (RTF_Info *info)
 
static void Destination (RTF_Info *info)
 
static void SpecialChar (RTF_Info *info)
 
static void RTFPutUnicodeChar (RTF_Info *info, int c)
 
void WriterInit (RTF_Info *info)
 
int BeginFile (RTF_Info *info)
 
static void RTFFlushUnicodeOutputBuffer (RTF_Info *info)
 
static void RTFPutUnicodeString (RTF_Info *info, const WCHAR *string, int length)
 
void RTFFlushOutputBuffer (RTF_Info *info)
 

Variables

static RTFKey rtfKey []
 
static RTFHashTableEntry rtfHashTable [RTF_KEY_COUNT *2]
 

Macro Definition Documentation

#define RTF_KEY_COUNT   (sizeof(rtfKey) / sizeof(RTFKey))

Definition at line 2167 of file reader.c.

Referenced by Lookup(), LookupCleanup(), and LookupInit().

Typedef Documentation

typedef struct RTFKey RTFKey

Definition at line 1248 of file reader.c.

Function Documentation

int _RTFGetChar ( RTF_Info info)
static

Definition at line 84 of file reader.c.

Referenced by GetChar().

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 }
ME_InStream * stream
Definition: rtf.h:1147
void ME_StreamInFill(ME_InStream *stream)
Definition: editor.c:1567
unsigned char
Definition: typeof.h:27
DWORD dwSize
Definition: editstr.h:341
if(!(yy_init))
Definition: macro.lex.yy.c:704
EDITSTREAM * editstream
Definition: editstr.h:340
Definition: parse.h:22
char buffer[STREAMIN_BUFFER_SIZE]
Definition: editstr.h:343
DWORD dwError
Definition: richedit.h:521
DWORD dwUsed
Definition: editstr.h:342
#define EOF
Definition: stdio.h:24
static void _RTFGetToken ( RTF_Info info)
static

Definition at line 443 of file reader.c.

Referenced by RTFGetToken().

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 }
int pushedParam
Definition: rtf.h:1130
static void _RTFGetToken2(RTF_Info *)
Definition: reader.c:543
int pushedMinor
Definition: rtf.h:1129
int pushedClass
Definition: rtf.h:1127
int rtfParam
Definition: rtf.h:1112
int rtfTextLen
Definition: rtf.h:1115
char * rtfTextBuf
Definition: rtf.h:1114
int pushedMajor
Definition: rtf.h:1128
int rtfMinor
Definition: rtf.h:1111
#define SF_TEXT
Definition: richedit.h:718
int rtfClass
Definition: rtf.h:1109
char * pushedTextBuf
Definition: rtf.h:1131
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:98
#define rtfText
Definition: rtf.h:70
static int GetChar(RTF_Info *)
Definition: reader.c:714
int rtfFormat
Definition: rtf.h:1113
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:143
int rtfMajor
Definition: rtf.h:1110
#define rtfNoParam
Definition: rtf.h:52
#define EOF
Definition: stdio.h:24
#define rtfEOF
Definition: rtf.h:72
static void _RTFGetToken2 ( RTF_Info info)
static

Definition at line 543 of file reader.c.

Referenced by _RTFGetToken().

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 }
static size_t double int int int * sign
Definition: printf.c:63
#define rtfUnknown
Definition: rtf.h:68
#define rtfBeginGroup
Definition: rtf.h:79
#define rtfEndGroup
Definition: rtf.h:80
ME_InStream * stream
Definition: rtf.h:1147
#define isalpha(c)
Definition: acclib.h:74
#define rtfSpecialChar
Definition: rtf.h:196
int rtfParam
Definition: rtf.h:1112
#define rtfGroup
Definition: rtf.h:69
int rtfTextLen
Definition: rtf.h:1115
char * rtfTextBuf
Definition: rtf.h:1114
static void Lookup(RTF_Info *, char *)
Definition: reader.c:2218
#define isdigit(c)
Definition: acclib.h:68
int rtfMinor
Definition: rtf.h:1111
int rtfClass
Definition: rtf.h:1109
int pushedChar
Definition: rtf.h:1125
#define rtfTab
Definition: rtf.h:236
#define rtfText
Definition: rtf.h:70
static int GetChar(RTF_Info *)
Definition: reader.c:714
#define rtfControl
Definition: rtf.h:71
EDITSTREAM * editstream
Definition: editstr.h:340
int rtfMajor
Definition: rtf.h:1110
DWORD dwError
Definition: richedit.h:521
#define rtfNoParam
Definition: rtf.h:52
#define isxdigit(c)
Definition: acclib.h:70
#define EOF
Definition: stdio.h:24
#define c
Definition: ke_i.h:80
int RTFCharToHex(char c)
Definition: reader.c:2287
#define rtfEOF
Definition: rtf.h:72
int BeginFile ( RTF_Info info)

Definition at line 2325 of file reader.c.

Referenced by ME_StreamIn().

2326 {
2327  /* install class callbacks */
2328 
2331 
2332  return (1);
2333 }
static void RTFSetClassCallback(RTF_Info *info, int class, RTFFuncPtr callback)
Definition: reader.c:180
static void ControlClass(RTF_Info *info)
Definition: reader.c:2347
#define rtfText
Definition: rtf.h:70
#define rtfControl
Definition: rtf.h:71
static void TextClass(RTF_Info *info)
Definition: reader.c:2340
static void CharAttr ( RTF_Info info)
static

Definition at line 2382 of file reader.c.

Referenced by ControlClass().

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 }
int codePage
Definition: rtf.h:1145
RTFFont * RTFGetFont(const RTF_Info *info, int num)
Definition: reader.c:1211
int rtfParam
Definition: rtf.h:1112
#define rtfUnicodeLength
Definition: rtf.h:589
Definition: rtf.h:949
#define CP_UTF8
Definition: nls.h:21
void RTFFlushOutputBuffer(RTF_Info *info)
Definition: reader.c:2616
int rtfMinor
Definition: rtf.h:1111
#define TRACE(s)
Definition: solgame.cpp:4
int unicodeLength
Definition: rtf.h:1144
int ansiCodePage
Definition: rtf.h:1140
int rtfFCodePage
Definition: rtf.h:958
#define ERR(fmt,...)
Definition: debug.h:109
#define rtfFontNum
Definition: rtf.h:563
static void CharSet ( RTF_Info info)
static

Definition at line 2410 of file reader.c.

Referenced by ControlClass(), and main().

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 }
#define rtfAnsiCharSet
Definition: rtf.h:91
#define rtfMacCharSet
Definition: rtf.h:92
#define CP_UTF8
Definition: nls.h:21
#define rtfPcCharSet
Definition: rtf.h:93
int rtfMinor
Definition: rtf.h:1111
int ansiCodePage
Definition: rtf.h:1140
#define rtfPcaCharSet
Definition: rtf.h:94
static void ControlClass ( RTF_Info info)
static

Definition at line 2347 of file reader.c.

Referenced by BeginFile().

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 }
static void DefFont(RTF_Info *info)
Definition: reader.c:2447
static void Destination(RTF_Info *info)
Definition: reader.c:2439
#define rtfCharSet
Definition: rtf.h:90
#define rtfSpecialChar
Definition: rtf.h:196
static void CharSet(RTF_Info *info)
Definition: reader.c:2410
static void CharAttr(RTF_Info *info)
Definition: reader.c:2382
void ME_RTFCharAttrHook(RTF_Info *info)
Definition: editor.c:416
#define rtfParAttr
Definition: rtf.h:445
void ME_RTFParAttrHook(RTF_Info *info)
Definition: editor.c:547
#define rtfTblAttr
Definition: rtf.h:404
void ME_RTFSpecialCharHook(RTF_Info *info)
Definition: editor.c:943
void ME_RTFTblAttrHook(RTF_Info *info)
Definition: editor.c:869
#define rtfDefFont
Definition: rtf.h:88
#define rtfCharAttr
Definition: rtf.h:552
static void DocAttr(RTF_Info *info)
Definition: reader.c:2455
#define rtfDestination
Definition: rtf.h:99
int rtfMajor
Definition: rtf.h:1110
#define rtfDocAttr
Definition: rtf.h:266
static void SpecialChar(RTF_Info *info)
Definition: reader.c:2471
static void DefFont ( RTF_Info info)
static

Definition at line 2447 of file reader.c.

Referenced by ControlClass().

2448 {
2449  TRACE("%d\n", info->rtfParam);
2450  info->defFont = info->rtfParam;
2451 }
int rtfParam
Definition: rtf.h:1112
#define TRACE(s)
Definition: solgame.cpp:4
int defFont
Definition: rtf.h:1141
static void Destination ( RTF_Info info)
static

Definition at line 2439 of file reader.c.

Referenced by ControlClass().

2440 {
2441  if (!RTFGetDestinationCallback(info, info->rtfMinor))
2442  RTFSkipGroup (info);
2443 }
void RTFSkipGroup(RTF_Info *info)
Definition: reader.c:343
int rtfMinor
Definition: rtf.h:1111
static RTFFuncPtr RTFGetDestinationCallback(const RTF_Info *info, int dest)
Definition: reader.c:277
static void DocAttr ( RTF_Info info)
static

Definition at line 2455 of file reader.c.

Referenced by ControlClass().

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 }
int codePage
Definition: rtf.h:1145
#define rtfAnsiCodePage
Definition: rtf.h:345
#define rtfUTF8RTF
Definition: rtf.h:346
int rtfParam
Definition: rtf.h:1112
#define CP_UTF8
Definition: nls.h:21
int rtfMinor
Definition: rtf.h:1111
#define TRACE(s)
Definition: solgame.cpp:4
int ansiCodePage
Definition: rtf.h:1140
static int GetChar ( RTF_Info info)
static

Definition at line 714 of file reader.c.

Referenced by _RTFGetToken(), and _RTFGetToken2().

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 }
#define TRUE
Definition: numbers.c:17
int rtfLineNum
Definition: rtf.h:1117
int rtfTextLen
Definition: rtf.h:1115
char * rtfTextBuf
Definition: rtf.h:1114
static int _RTFGetChar(RTF_Info *)
Definition: reader.c:84
BOOL bumpLine
Definition: rtf.h:1134
unsigned int BOOL
Definition: ntddk_ex.h:94
int prevChar
Definition: rtf.h:1133
int rtfLinePos
Definition: rtf.h:1118
#define EOF
Definition: stdio.h:24
#define FALSE
Definition: numbers.c:16
#define c
Definition: ke_i.h:80
static void Lookup ( RTF_Info info,
char s 
)
static

Definition at line 2218 of file reader.c.

Referenced by _RTFGetToken2(), ApphelpCacheLookupEntry(), ApphelpCacheUpdateEntry(), and RtlLookupElementGenericTableAvl().

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 }
static int Hash(const char *)
Definition: reader.c:2247
#define rtfUnknown
Definition: rtf.h:68
int rtfKMinor
Definition: reader.c:1253
RTFKey ** value
Definition: reader.c:2171
uint8_t entry
Definition: isohybrid.c:63
#define RTF_KEY_COUNT
Definition: reader.c:2167
GLenum GLclampf GLint i
Definition: glfuncs.h:14
int hash
Definition: main.c:58
int rtfMinor
Definition: rtf.h:1111
int rtfClass
Definition: rtf.h:1109
#define rtfControl
Definition: rtf.h:71
GLdouble s
Definition: gl.h:2039
int rtfKMajor
Definition: reader.c:1252
int rtfMajor
Definition: rtf.h:1110
const char * rtfKStr
Definition: reader.c:1254
static RTFHashTableEntry rtfHashTable[RTF_KEY_COUNT *2]
Definition: reader.c:2174
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int rtfKHash
Definition: reader.c:1255
void LookupCleanup ( void  )

Definition at line 2200 of file reader.c.

Referenced by DllMain().

2201 {
2202  unsigned int i;
2203 
2204  for (i=0; i<RTF_KEY_COUNT*2; i++)
2205  {
2207  rtfHashTable[i].value = NULL;
2208  rtfHashTable[i].count = 0;
2209  }
2210 }
Definition: get.c:139
RTFKey ** value
Definition: reader.c:2171
#define RTF_KEY_COUNT
Definition: reader.c:2167
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define NULL
Definition: mystdio.h:57
static BOOL heap_free(void *mem)
Definition: wscript.h:65
static RTFHashTableEntry rtfHashTable[RTF_KEY_COUNT *2]
Definition: reader.c:2174
void LookupInit ( void  )

Definition at line 2181 of file reader.c.

Referenced by DllMain().

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));
2197  }
2198 }
static int Hash(const char *)
Definition: reader.c:2247
Definition: get.c:139
RTFKey ** value
Definition: reader.c:2171
void * heap_alloc(unsigned size) DECLSPEC_HIDDEN __WINE_ALLOC_SIZE(1)
#define RTF_KEY_COUNT
Definition: reader.c:2167
#define NULL
Definition: mystdio.h:57
void * heap_realloc(void *ptr, unsigned size) DECLSPEC_HIDDEN
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define index(s, c)
Definition: various.h:29
static RTFKey rtfKey[]
Definition: reader.c:1263
const char * rtfKStr
Definition: reader.c:1254
static RTFHashTableEntry rtfHashTable[RTF_KEY_COUNT *2]
Definition: reader.c:2174
int rtfKHash
Definition: reader.c:1255
#define memset(x, y, z)
Definition: compat.h:39
static void ReadColorTbl ( RTF_Info info)
static

Definition at line 954 of file reader.c.

Referenced by RTFInit().

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 }
Definition: rtf.h:968
#define rtfBeginGroup
Definition: rtf.h:79
#define rtfEndGroup
Definition: rtf.h:80
#define rtfRed
Definition: rtf.h:192
#define New(t)
Definition: rtf.h:1076
int rtfParam
Definition: rtf.h:1112
int rtfCRed
Definition: rtf.h:971
#define rtfGroup
Definition: rtf.h:69
RTFColor * colorList
Definition: rtf.h:1138
#define NULL
Definition: mystdio.h:57
int RTFCheckCM(const RTF_Info *info, int class, int major)
Definition: reader.c:2266
int rtfCGreen
Definition: rtf.h:972
int rtfMinor
Definition: rtf.h:1111
int rtfCBlue
Definition: rtf.h:973
int rtfClass
Definition: rtf.h:1109
int RTFGetToken(RTF_Info *info)
Definition: reader.c:395
#define rtfBlue
Definition: rtf.h:194
#define rtfText
Definition: rtf.h:70
#define rtfControl
Definition: rtf.h:71
#define rtfGreen
Definition: rtf.h:193
#define ERR(fmt,...)
Definition: debug.h:109
int rtfCNum
Definition: rtf.h:970
POINT cp
Definition: magnifier.c:58
#define rtfColorName
Definition: rtf.h:191
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:310
RTFColor * rtfNextColor
Definition: rtf.h:974
#define rtfEOF
Definition: rtf.h:72
static void ReadFontTbl ( RTF_Info info)
static

Definition at line 775 of file reader.c.

Referenced by RTFInit().

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 }
int codePage
Definition: rtf.h:1145
int rtfFFamily
Definition: rtf.h:954
int rtfFCharSet
Definition: rtf.h:955
#define FF_DONTCARE
Definition: wingdi.h:446
#define rtfBeginGroup
Definition: rtf.h:79
#define rtfEndGroup
Definition: rtf.h:80
static char * RTFStrSave(const char *s)
Definition: reader.c:70
#define CP_ACP
Definition: compat.h:99
#define WARN(fmt,...)
Definition: debug.h:111
char * rtfFAltName
Definition: rtf.h:952
char * rtfFName
Definition: rtf.h:951
int rtfFType
Definition: rtf.h:957
#define rtfFontCharSet
Definition: rtf.h:725
#define New(t)
Definition: rtf.h:1076
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
int rtfParam
Definition: rtf.h:1112
#define rtfGroup
Definition: rtf.h:69
#define DEFAULT_CHARSET
Definition: wingdi.h:382
Definition: rtf.h:949
void RTFSkipGroup(RTF_Info *info)
Definition: reader.c:343
int RTFCharSetToCodePage(RTF_Info *info, int charset)
Definition: reader.c:482
#define rtfFTypeNil
Definition: rtf.h:728
char * rtfTextBuf
Definition: rtf.h:1114
#define CP_UTF8
Definition: nls.h:21
#define rtfFontFamily
Definition: rtf.h:181
#define NULL
Definition: mystdio.h:57
int RTFCheckCM(const RTF_Info *info, int class, int major)
Definition: reader.c:2266
#define rtfBufSiz
Definition: rtf.h:20
#define rtfFontPitch
Definition: rtf.h:726
int rtfMinor
Definition: rtf.h:1111
RTFFont * fontList
Definition: rtf.h:1137
#define TRACE(s)
Definition: solgame.cpp:4
int rtfClass
Definition: rtf.h:1109
#define DEFAULT_PITCH
Definition: wingdi.h:441
int RTFGetToken(RTF_Info *info)
Definition: reader.c:395
int defFont
Definition: rtf.h:1141
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:98
#define rtfText
Definition: rtf.h:70
#define rtfCharAttr
Definition: rtf.h:552
#define rtfControl
Definition: rtf.h:71
int ansiCodePage
Definition: rtf.h:1140
int rtfFCodePage
Definition: rtf.h:958
#define ERR(fmt,...)
Definition: debug.h:109
#define rtfFontAttr
Definition: rtf.h:724
static void RTFUngetToken(RTF_Info *info)
Definition: reader.c:420
int rtfMajor
Definition: rtf.h:1110
int RTFCheckCMM(const RTF_Info *info, int class, int major, int minor)
Definition: reader.c:2272
#define rtfFTypeTrueType
Definition: rtf.h:729
int rtfFNum
Definition: rtf.h:953
RTFFont * rtfNextFont
Definition: rtf.h:959
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:310
#define rtfFontNum
Definition: rtf.h:563
int rtfFPitch
Definition: rtf.h:956
#define rtfFontCodePage
Definition: rtf.h:727
#define rtfEOF
Definition: rtf.h:72
static void ReadInfoGroup ( RTF_Info info)
static

Definition at line 1183 of file reader.c.

Referenced by RTFInit().

1184 {
1185  RTFSkipGroup (info);
1186  RTFRouteToken (info); /* feed "}" back to router */
1187 }
void RTFSkipGroup(RTF_Info *info)
Definition: reader.c:343
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:310
static void ReadObjGroup ( RTF_Info info)
static

Definition at line 1197 of file reader.c.

Referenced by RTFInit().

1198 {
1199  RTFSkipGroup (info);
1200  RTFRouteToken (info); /* feed "}" back to router */
1201 }
void RTFSkipGroup(RTF_Info *info)
Definition: reader.c:343
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:310
static void ReadPictGroup ( RTF_Info info)
static

Definition at line 1190 of file reader.c.

Referenced by RTFInit().

1191 {
1192  RTFSkipGroup (info);
1193  RTFRouteToken (info); /* feed "}" back to router */
1194 }
void RTFSkipGroup(RTF_Info *info)
Definition: reader.c:343
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:310
static void ReadStyleSheet ( RTF_Info info)
static

Definition at line 1014 of file reader.c.

Referenced by RTFInit().

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 }
int rtfSEParam
Definition: rtf.h:997
int rtfSEMinor
Definition: rtf.h:996
#define rtfBeginGroup
Definition: rtf.h:79
RTFStyle * rtfNextStyle
Definition: rtf.h:988
int rtfExpanding
Definition: rtf.h:987
#define rtfNormalStyleNum
Definition: rtf.h:61
#define rtfEndGroup
Definition: rtf.h:80
static char * RTFStrSave(const char *s)
Definition: reader.c:70
RTFStyleElt * rtfNextSE
Definition: rtf.h:999
#define WARN(fmt,...)
Definition: debug.h:111
#define TRUE
Definition: numbers.c:17
#define New(t)
Definition: rtf.h:1076
int rtfSNextPar
Definition: rtf.h:985
#define rtfSectAttr
Definition: rtf.h:348
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define rtfSpecialChar
Definition: rtf.h:196
int rtfSBasedOn
Definition: rtf.h:984
int rtfParam
Definition: rtf.h:1112
int rtfSAdditive
Definition: rtf.h:982
int rtfSType
Definition: rtf.h:981
#define rtfGroup
Definition: rtf.h:69
void RTFSkipGroup(RTF_Info *info)
Definition: reader.c:343
int rtfSNum
Definition: rtf.h:983
char * rtfTextBuf
Definition: rtf.h:1114
#define rtfCharStyle
Definition: rtf.h:933
#define rtfSectStyle
Definition: rtf.h:934
#define NULL
Definition: mystdio.h:57
char * rtfSName
Definition: rtf.h:980
int RTFCheckCM(const RTF_Info *info, int class, int major)
Definition: reader.c:2266
#define rtfParAttr
Definition: rtf.h:445
#define rtfBufSiz
Definition: rtf.h:20
int rtfMinor
Definition: rtf.h:1111
#define rtfOptDest
Definition: rtf.h:250
int rtfClass
Definition: rtf.h:1109
int rtfSEClass
Definition: rtf.h:994
int RTFGetToken(RTF_Info *info)
Definition: reader.c:395
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
int rtfSEMajor
Definition: rtf.h:995
#define rtfCharStyleNum
Definition: rtf.h:585
#define rtfText
Definition: rtf.h:70
#define rtfStyleNum
Definition: rtf.h:447
#define rtfCharAttr
Definition: rtf.h:552
#define rtfControl
Definition: rtf.h:71
int RTFCheckMM(const RTF_Info *info, int major, int minor)
Definition: reader.c:2278
#define rtfParStyle
Definition: rtf.h:932
#define ERR(fmt,...)
Definition: debug.h:109
static void RTFUngetToken(RTF_Info *info)
Definition: reader.c:420
int rtfMajor
Definition: rtf.h:1110
#define rtfNext
Definition: rtf.h:264
char * rtfSEText
Definition: rtf.h:998
#define FALSE
Definition: numbers.c:16
#define rtfNoStyleNum
Definition: rtf.h:60
static const WCHAR sp[]
Definition: suminfo.c:288
#define rtfAdditive
Definition: rtf.h:262
#define rtfStyleAttr
Definition: rtf.h:261
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:310
RTFStyleElt * rtfSSEList
Definition: rtf.h:986
#define rtfBasedOn
Definition: rtf.h:263
Definition: rtf.h:978
RTFStyle * styleList
Definition: rtf.h:1139
#define rtfSectStyleNum
Definition: rtf.h:353
#define rtfEOF
Definition: rtf.h:72
int RTFCharSetToCodePage ( RTF_Info info,
int  charset 
)

Definition at line 482 of file reader.c.

Referenced by ME_StreamOutRTFCharProps(), and ReadFontTbl().

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 }
#define MAC_CHARSET
Definition: wingdi.h:401
CFF_Charset charset
Definition: cffcmap.c:132
#define EASTEUROPE_CHARSET
Definition: wingdi.h:397
#define CP_ACP
Definition: compat.h:99
#define SYMBOL_CHARSET
Definition: wingdi.h:383
#define CHINESEBIG5_CHARSET
Definition: wingdi.h:388
#define DEFAULT_CHARSET
Definition: wingdi.h:382
#define CP_SYMBOL
Definition: winnls.h:222
DWORD DWORD
Definition: winlogon.h:75
GLuint n
Definition: s_context.h:57
#define TURKISH_CHARSET
Definition: wingdi.h:390
BOOL WINAPI TranslateCharsetInfo(_Inout_ PDWORD, _Out_ LPCHARSETINFO, _In_ DWORD)
#define THAI_CHARSET
Definition: wingdi.h:395
#define SHIFTJIS_CHARSET
Definition: wingdi.h:384
#define RUSSIAN_CHARSET
Definition: wingdi.h:394
#define OEM_CHARSET
Definition: wingdi.h:398
#define GB2312_CHARSET
Definition: wingdi.h:387
#define ERR(fmt,...)
Definition: debug.h:109
#define VIETNAMESE_CHARSET
Definition: wingdi.h:400
#define HEBREW_CHARSET
Definition: wingdi.h:391
#define ARABIC_CHARSET
Definition: wingdi.h:392
#define HANGEUL_CHARSET
Definition: wingdi.h:385
#define ANSI_CHARSET
Definition: wingdi.h:381
#define JOHAB_CHARSET
Definition: wingdi.h:399
#define BALTIC_CHARSET
Definition: wingdi.h:393
#define GREEK_CHARSET
Definition: wingdi.h:389
#define CP_OEMCP
Definition: winnls.h:219
#define TCI_SRCCHARSET
Definition: wingdi.h:959
#define CP_MACCP
Definition: winnls.h:220
int RTFCharToHex ( char  c)

Definition at line 2287 of file reader.c.

Referenced by _RTFGetToken2(), and read_hex_data().

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 }
#define isdigit(c)
Definition: acclib.h:68
#define isupper(c)
Definition: acclib.h:71
const GLubyte * c
Definition: glext.h:8905
int tolower(int c)
Definition: utclib.c:902
int RTFCheckCM ( const RTF_Info info,
int  class,
int  major 
)

Definition at line 2266 of file reader.c.

Referenced by ME_RTFReadObjectGroup(), ME_RTFReadParnumGroup(), ME_RTFReadPictGroup(), ME_RTFReadShpPictGroup(), ReadColorTbl(), ReadFontTbl(), ReadStyleSheet(), RTFRouteToken(), and RTFUngetToken().

2267 {
2268  return (info->rtfClass == class && info->rtfMajor == major);
2269 }
#define major(dev)
Definition: device.h:104
int rtfClass
Definition: rtf.h:1109
int rtfMajor
Definition: rtf.h:1110
int RTFCheckCMM ( const RTF_Info info,
int  class,
int  major,
int  minor 
)

Definition at line 2272 of file reader.c.

Referenced by ME_RTFReadObjectGroup(), ME_RTFReadParnumGroup(), and ReadFontTbl().

2273 {
2274  return (info->rtfClass == class && info->rtfMajor == major && info->rtfMinor == minor);
2275 }
#define major(dev)
Definition: device.h:104
#define minor(dev)
Definition: device.h:105
int rtfMinor
Definition: rtf.h:1111
int rtfClass
Definition: rtf.h:1109
int rtfMajor
Definition: rtf.h:1110
int RTFCheckMM ( const RTF_Info info,
int  major,
int  minor 
)

Definition at line 2278 of file reader.c.

Referenced by ME_RTFReadPictGroup(), and ReadStyleSheet().

2279 {
2280  return (info->rtfMajor == major && info->rtfMinor == minor);
2281 }
#define major(dev)
Definition: device.h:104
#define minor(dev)
Definition: device.h:105
int rtfMinor
Definition: rtf.h:1111
int rtfMajor
Definition: rtf.h:1110
void RTFDestroy ( RTF_Info info)

Definition at line 150 of file reader.c.

Referenced by ME_StreamIn().

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 }
static void RTFDestroyAttrs(RTF_Info *info)
Definition: reader.c:111
RTFTable * tableDef
Definition: rtf.h:1170
char * rtfTextBuf
Definition: rtf.h:1114
RTFTable * parent
Definition: rtf.h:1034
char * pushedTextBuf
Definition: rtf.h:1131
char * cpOutputBuffer
Definition: rtf.h:1163
static BOOL heap_free(void *mem)
Definition: wscript.h:65
Definition: rtf.h:1015
static void RTFDestroyAttrs ( RTF_Info info)
static

Definition at line 111 of file reader.c.

Referenced by RTFDestroy(), and RTFInit().

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 }
Definition: rtf.h:968
RTFStyle * rtfNextStyle
Definition: rtf.h:988
RTFStyleElt * rtfNextSE
Definition: rtf.h:999
char * rtfFName
Definition: rtf.h:951
Definition: rtf.h:949
RTFColor * colorList
Definition: rtf.h:1138
char * rtfSName
Definition: rtf.h:980
RTFFont * fontList
Definition: rtf.h:1137
static BOOL heap_free(void *mem)
Definition: wscript.h:65
char * rtfSEText
Definition: rtf.h:998
POINT cp
Definition: magnifier.c:58
static const WCHAR sp[]
Definition: suminfo.c:288
RTFFont * rtfNextFont
Definition: rtf.h:959
RTFStyleElt * rtfSSEList
Definition: rtf.h:986
RTFColor * rtfNextColor
Definition: rtf.h:974
Definition: rtf.h:978
RTFStyle * styleList
Definition: rtf.h:1139
static void RTFFlushCPOutputBuffer ( RTF_Info info)
static

Definition at line 2601 of file reader.c.

Referenced by RTFFlushOutputBuffer(), RTFPutUnicodeChar(), and RTFPutUnicodeString().

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 }
int codePage
Definition: rtf.h:1145
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLuint buffer
Definition: glext.h:5915
#define WCHAR
Definition: msvc.h:43
void * heap_alloc(unsigned size) DECLSPEC_HIDDEN __WINE_ALLOC_SIZE(1)
DWORD dwCPOutputCount
Definition: rtf.h:1161
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
char * cpOutputBuffer
Definition: rtf.h:1163
static BOOL heap_free(void *mem)
Definition: wscript.h:65
#define MultiByteToWideChar
Definition: compat.h:100
static void RTFPutUnicodeString(RTF_Info *info, const WCHAR *string, int length)
Definition: reader.c:2583
void RTFFlushOutputBuffer ( RTF_Info info)

Definition at line 2616 of file reader.c.

Referenced by CharAttr(), ME_RTFCharAttrHook(), ME_RTFParAttrHook(), ME_RTFReadHook(), ME_RTFSpecialCharHook(), ME_StreamIn(), and SpecialChar().

2617 {
2618  if (info->dwCPOutputCount)
2619  RTFFlushCPOutputBuffer(info);
2621 }
static void RTFFlushCPOutputBuffer(RTF_Info *info)
Definition: reader.c:2601
static void RTFFlushUnicodeOutputBuffer(RTF_Info *info)
Definition: reader.c:2571
DWORD dwCPOutputCount
Definition: rtf.h:1161
static void RTFFlushUnicodeOutputBuffer ( RTF_Info info)
static

Definition at line 2571 of file reader.c.

Referenced by RTFFlushOutputBuffer(), RTFPutUnicodeChar(), and RTFPutUnicodeString().

2572 {
2573  if (info->dwOutputCount)
2574  {
2576  info->dwOutputCount, info->style);
2577  info->dwOutputCount = 0;
2578  }
2579 }
DWORD dwOutputCount
Definition: rtf.h:1158
ME_TextEditor * editor
Definition: rtf.h:1149
void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor, const WCHAR *str, int len, ME_Style *style)
Definition: caret.c:508
ME_Style * style
Definition: rtf.h:1150
WCHAR OutputBuffer[0x1000]
Definition: rtf.h:1159
static RTFFuncPtr RTFGetClassCallback ( const RTF_Info info,
int  class 
)
static

Definition at line 187 of file reader.c.

Referenced by RTFRouteToken().

188 {
189  if (class >= 0 && class < rtfMaxClass)
190  return info->ccb[class];
191  return NULL;
192 }
#define NULL
Definition: mystdio.h:57
#define rtfMaxClass
Definition: rtf.h:73
RTFFuncPtr ccb[rtfMaxClass]
Definition: rtf.h:1152
RTFColor* RTFGetColor ( const RTF_Info info,
int  num 
)

Definition at line 1226 of file reader.c.

Referenced by ME_RTFCharAttrHook().

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 }
Definition: rtf.h:968
RTFColor * colorList
Definition: rtf.h:1138
#define NULL
Definition: mystdio.h:57
GLuint GLuint num
Definition: glext.h:9618
int rtfCNum
Definition: rtf.h:970
#define c
Definition: ke_i.h:80
RTFColor * rtfNextColor
Definition: rtf.h:974
static RTFFuncPtr RTFGetDestinationCallback ( const RTF_Info info,
int  dest 
)
static

Definition at line 277 of file reader.c.

Referenced by Destination(), and RTFRouteToken().

278 {
279  if (dest >= 0 && dest < rtfMaxDestination)
280  return info->dcb[dest];
281  return NULL;
282 }
#define NULL
Definition: mystdio.h:57
GLfloat CONST GLvector4f CONST GLfloat GLvector4f * dest
Definition: m_xform.h:122
RTFFuncPtr dcb[rtfMaxDestination]
Definition: rtf.h:1154
#define rtfMaxDestination
Definition: rtf.h:179
RTFFont* RTFGetFont ( const RTF_Info info,
int  num 
)

Definition at line 1211 of file reader.c.

Referenced by CharAttr(), and ME_RTFCharAttrHook().

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 }
Definition: rtf.h:949
#define NULL
Definition: mystdio.h:57
RTFFont * fontList
Definition: rtf.h:1137
GLuint GLuint num
Definition: glext.h:9618
#define f
Definition: ke_i.h:83
int rtfFNum
Definition: rtf.h:953
RTFFont * rtfNextFont
Definition: rtf.h:959
static RTFFuncPtr RTFGetReadHook ( const RTF_Info info)
static

Definition at line 383 of file reader.c.

Referenced by RTFGetToken().

384 {
385  return (info->readHook);
386 }
RTFFuncPtr readHook
Definition: rtf.h:1156
int RTFGetToken ( RTF_Info info)

Definition at line 395 of file reader.c.

Referenced by ME_RTFReadObjectGroup(), ME_RTFReadParnumGroup(), ME_RTFReadPictGroup(), ME_RTFReadShpPictGroup(), read_hex_data(), ReadColorTbl(), ReadFontTbl(), ReadStyleSheet(), RTFRead(), RTFSkipGroup(), and SpecialChar().

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 }
static RTFFuncPtr RTFGetReadHook(const RTF_Info *info)
Definition: reader.c:383
static void _RTFGetToken(RTF_Info *)
Definition: reader.c:443
#define NULL
Definition: mystdio.h:57
#define SF_TEXT
Definition: richedit.h:718
int rtfClass
Definition: rtf.h:1109
void(* RTFFuncPtr)(RTF_Info *)
Definition: rtf.h:1085
#define rtfText
Definition: rtf.h:70
int rtfFormat
Definition: rtf.h:1113
const XML_Char XML_Encoding * info
Definition: expat.h:530
int rtfMajor
Definition: rtf.h:1110
GLfloat GLfloat p
Definition: glext.h:8902
#define rtfEOF
Definition: rtf.h:72
void RTFInit ( RTF_Info info)

Definition at line 201 of file reader.c.

Referenced by ME_StreamIn().

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 }
PARAFORMAT2 fmt
Definition: rtf.h:1175
static void RTFDestroyAttrs(RTF_Info *info)
Definition: reader.c:111
int codePage
Definition: rtf.h:1145
#define rtfFontTbl
Definition: rtf.h:100
static void RTFSetClassCallback(RTF_Info *info, int class, RTFFuncPtr callback)
Definition: reader.c:180
int pushedClass
Definition: rtf.h:1127
RTFTable * tableDef
Definition: rtf.h:1170
static void ReadObjGroup(RTF_Info *)
Definition: reader.c:1197
int rtfLineNum
Definition: rtf.h:1117
static void ReadColorTbl(RTF_Info *)
Definition: reader.c:954
#define rtfColorTbl
Definition: rtf.h:106
void * heap_alloc(unsigned size) DECLSPEC_HIDDEN __WINE_ALLOC_SIZE(1)
char * rtfTextBuf
Definition: rtf.h:1114
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define NULL
Definition: mystdio.h:57
DWORD dwCPOutputCount
Definition: rtf.h:1161
#define rtfBufSiz
Definition: rtf.h:20
static void ReadPictGroup(RTF_Info *)
Definition: reader.c:1190
BOOL bumpLine
Definition: rtf.h:1134
int rtfClass
Definition: rtf.h:1109
void RTFSetDestinationCallback(RTF_Info *info, int dest, RTFFuncPtr callback)
Definition: reader.c:270
int unicodeLength
Definition: rtf.h:1144
int pushedChar
Definition: rtf.h:1125
char * pushedTextBuf
Definition: rtf.h:1131
char * cpOutputBuffer
Definition: rtf.h:1163
int defFont
Definition: rtf.h:1141
#define rtfInfo
Definition: rtf.h:110
#define rtfMaxClass
Definition: rtf.h:73
int ansiCodePage
Definition: rtf.h:1140
#define rtfMaxDestination
Definition: rtf.h:179
static void ReadStyleSheet(RTF_Info *)
Definition: reader.c:1014
int prevChar
Definition: rtf.h:1133
#define rtfPict
Definition: rtf.h:144
#define ERR(fmt,...)
Definition: debug.h:109
#define rtfStyleSheet
Definition: rtf.h:107
static void ReadInfoGroup(RTF_Info *)
Definition: reader.c:1183
#define rtfObject
Definition: rtf.h:145
int nestingLevel
Definition: rtf.h:1171
static void ReadFontTbl(RTF_Info *)
Definition: reader.c:775
int rtfLinePos
Definition: rtf.h:1118
void RTFSetReadHook(RTF_Info *info, RTFFuncPtr f)
Definition: reader.c:377
DWORD dwMaxCPOutputCount
Definition: rtf.h:1162
#define EOF
Definition: stdio.h:24
#define FALSE
Definition: numbers.c:16
UINT cbSize
Definition: richedit.h:664
BOOL canInheritInTbl
Definition: rtf.h:1172
#define memset(x, y, z)
Definition: compat.h:39
int borderType
Definition: rtf.h:1173
static void RTFPutCodePageChar ( RTF_Info info,
int  c 
)
static

Definition at line 2634 of file reader.c.

Referenced by TextClass().

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 }
DWORD dwCPOutputCount
Definition: rtf.h:1161
void * heap_realloc(void *ptr, unsigned size) DECLSPEC_HIDDEN
char * cpOutputBuffer
Definition: rtf.h:1163
DWORD dwMaxCPOutputCount
Definition: rtf.h:1162
#define c
Definition: ke_i.h:80
static void RTFPutUnicodeChar ( RTF_Info info,
int  c 
)
static

Definition at line 2624 of file reader.c.

Referenced by SpecialChar().

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 }
DWORD dwOutputCount
Definition: rtf.h:1158
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void RTFFlushCPOutputBuffer(RTF_Info *info)
Definition: reader.c:2601
static void RTFFlushUnicodeOutputBuffer(RTF_Info *info)
Definition: reader.c:2571
DWORD dwCPOutputCount
Definition: rtf.h:1161
#define c
Definition: ke_i.h:80
WCHAR OutputBuffer[0x1000]
Definition: rtf.h:1159
static void RTFPutUnicodeString ( RTF_Info info,
const WCHAR string,
int  length 
)
static

Definition at line 2583 of file reader.c.

Referenced by RTFFlushCPOutputBuffer().

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 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
DWORD dwOutputCount
Definition: rtf.h:1158
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void RTFFlushCPOutputBuffer(RTF_Info *info)
Definition: reader.c:2601
static void RTFFlushUnicodeOutputBuffer(RTF_Info *info)
Definition: reader.c:2571
DWORD dwCPOutputCount
Definition: rtf.h:1161
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define min(a, b)
Definition: monoChain.cc:55
WCHAR OutputBuffer[0x1000]
Definition: rtf.h:1159
void RTFRead ( RTF_Info info)

Definition at line 297 of file reader.c.

Referenced by ME_StreamIn().

298 {
299  while (RTFGetToken (info) != rtfEOF)
300  RTFRouteToken (info);
301 }
int RTFGetToken(RTF_Info *info)
Definition: reader.c:395
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:310
#define rtfEOF
Definition: rtf.h:72
void RTFReadGroup ( RTF_Info info)

Definition at line 368 of file reader.c.

Referenced by ME_StreamIn().

369 {
370 }
void RTFRouteToken ( RTF_Info info)

Definition at line 310 of file reader.c.

Referenced by ME_RTFReadObjectGroup(), ME_RTFReadParnumGroup(), ME_RTFReadPictGroup(), ME_RTFReadShpPictGroup(), ReadColorTbl(), ReadFontTbl(), ReadInfoGroup(), ReadObjGroup(), ReadPictGroup(), ReadStyleSheet(), RTFRead(), and SpecialChar().

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 }
char * rtfTextBuf
Definition: rtf.h:1114
static RTFFuncPtr RTFGetClassCallback(const RTF_Info *info, int class)
Definition: reader.c:187
#define NULL
Definition: mystdio.h:57
int RTFCheckCM(const RTF_Info *info, int class, int major)
Definition: reader.c:2266
int rtfMinor
Definition: rtf.h:1111
int rtfClass
Definition: rtf.h:1109
void(* RTFFuncPtr)(RTF_Info *)
Definition: rtf.h:1085
#define rtfControl
Definition: rtf.h:71
#define rtfMaxClass
Definition: rtf.h:73
static RTFFuncPtr RTFGetDestinationCallback(const RTF_Info *info, int dest)
Definition: reader.c:277
#define ERR(fmt,...)
Definition: debug.h:109
const XML_Char XML_Encoding * info
Definition: expat.h:530
#define rtfDestination
Definition: rtf.h:99
GLfloat GLfloat p
Definition: glext.h:8902
static void RTFSetClassCallback ( RTF_Info info,
int  class,
RTFFuncPtr  callback 
)
static

Definition at line 180 of file reader.c.

Referenced by BeginFile(), and RTFInit().

181 {
182  if (class >= 0 && class < rtfMaxClass)
183  info->ccb[class] = callback;
184 }
MmuTrapHandler callback[0x30]
Definition: mmuobject.c:44
#define rtfMaxClass
Definition: rtf.h:73
RTFFuncPtr ccb[rtfMaxClass]
Definition: rtf.h:1152
void RTFSetDestinationCallback ( RTF_Info info,
int  dest,
RTFFuncPtr  callback 
)

Definition at line 270 of file reader.c.

Referenced by ME_StreamIn(), and RTFInit().

271 {
272  if (dest >= 0 && dest < rtfMaxDestination)
273  info->dcb[dest] = callback;
274 }
MmuTrapHandler callback[0x30]
Definition: mmuobject.c:44
GLfloat CONST GLvector4f CONST GLfloat GLvector4f * dest
Definition: m_xform.h:122
RTFFuncPtr dcb[rtfMaxDestination]
Definition: rtf.h:1154
#define rtfMaxDestination
Definition: rtf.h:179
void RTFSetEditStream ( RTF_Info info,
ME_InStream stream 
)

Definition at line 105 of file reader.c.

Referenced by ME_StreamIn().

106 {
107  info->stream = stream;
108 }
ME_InStream * stream
Definition: rtf.h:1147
GLuint GLuint stream
Definition: glext.h:7522
void RTFSetReadHook ( RTF_Info info,
RTFFuncPtr  f 
)

Definition at line 377 of file reader.c.

Referenced by ME_StreamIn(), and RTFInit().

378 {
379  info->readHook = f;
380 }
RTFFuncPtr readHook
Definition: rtf.h:1156
#define f
Definition: ke_i.h:83
void RTFSkipGroup ( RTF_Info info)

Definition at line 343 of file reader.c.

Referenced by Destination(), ME_RTFReadObjectGroup(), ME_RTFReadPictGroup(), ME_StreamIn(), ReadFontTbl(), ReadInfoGroup(), ReadObjGroup(), ReadPictGroup(), ReadStyleSheet(), and SpecialChar().

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 }
GLint level
Definition: gl.h:1546
#define rtfBeginGroup
Definition: rtf.h:79
#define rtfEndGroup
Definition: rtf.h:80
#define rtfGroup
Definition: rtf.h:69
int rtfClass
Definition: rtf.h:1109
int RTFGetToken(RTF_Info *info)
Definition: reader.c:395
int rtfMajor
Definition: rtf.h:1110
#define rtfEOF
Definition: rtf.h:72
static char* RTFStrSave ( const char s)
inlinestatic

Definition at line 70 of file reader.c.

Referenced by ReadFontTbl(), and ReadStyleSheet().

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 }
void * heap_alloc(unsigned size) DECLSPEC_HIDDEN __WINE_ALLOC_SIZE(1)
#define NULL
Definition: mystdio.h:57
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:98
GLdouble s
Definition: gl.h:2039
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:143
GLfloat GLfloat p
Definition: glext.h:8902
static void RTFUngetToken ( RTF_Info info)
static

Definition at line 420 of file reader.c.

Referenced by ReadFontTbl(), ReadStyleSheet(), and SpecialChar().

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 }
int pushedParam
Definition: rtf.h:1130
#define rtfEndGroup
Definition: rtf.h:80
int pushedMinor
Definition: rtf.h:1129
int pushedClass
Definition: rtf.h:1127
int rtfParam
Definition: rtf.h:1112
#define rtfGroup
Definition: rtf.h:69
ME_Style * style
Definition: rtf.h:1150
char * rtfTextBuf
Definition: rtf.h:1114
int pushedMajor
Definition: rtf.h:1128
int stackTop
Definition: rtf.h:1166
int RTFCheckCM(const RTF_Info *info, int class, int major)
Definition: reader.c:2266
int rtfMinor
Definition: rtf.h:1111
ME_Style * style
Definition: rtf.h:1090
int rtfClass
Definition: rtf.h:1109
char * pushedTextBuf
Definition: rtf.h:1131
void ME_AddRefStyle(ME_Style *item) DECLSPEC_HIDDEN
Definition: style.c:431
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:98
#define ERR(fmt,...)
Definition: debug.h:109
int rtfMajor
Definition: rtf.h:1110
RTFState stack[maxStack]
Definition: rtf.h:1165
static void SpecialChar ( RTF_Info info)
static

Definition at line 2471 of file reader.c.

Referenced by ControlClass().

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 }
#define rtfSect
Definition: rtf.h:228
PARAFORMAT2 fmt
Definition: rtf.h:1175
#define rtfRTLMark
Definition: rtf.h:252
#define rtfNoWidthJoiner
Definition: rtf.h:253
#define rtfRDblQuote
Definition: rtf.h:245
#define rtfEnDash
Definition: rtf.h:238
ME_TextEditor * editor
Definition: rtf.h:1149
#define rtfEmSpace
Definition: rtf.h:239
BOOL ME_SetSelectionParaFormat(ME_TextEditor *editor, const PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN
Definition: para.c:779
int rtfParam
Definition: rtf.h:1112
#define rtfEmDash
Definition: rtf.h:237
void ME_InsertEndRowFromCursor(ME_TextEditor *editor, int nCursor)
Definition: caret.c:493
void RTFSkipGroup(RTF_Info *info)
Definition: reader.c:343
#define rtfNoBrkSpace
Definition: rtf.h:247
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define rtfUnicode
Definition: rtf.h:257
#define rtfLDblQuote
Definition: rtf.h:244
#define rtfPage
Definition: rtf.h:229
void RTFFlushOutputBuffer(RTF_Info *info)
Definition: reader.c:2616
#define rtfPar
Definition: rtf.h:227
#define rtfNoBrkHyphen
Definition: rtf.h:249
int rtfMinor
Definition: rtf.h:1111
#define rtfEnSpace
Definition: rtf.h:240
#define rtfOptDest
Definition: rtf.h:250
#define rtfRQuote
Definition: rtf.h:243
int rtfClass
Definition: rtf.h:1109
int unicodeLength
Definition: rtf.h:1144
int RTFGetToken(RTF_Info *info)
Definition: reader.c:395
#define rtfTab
Definition: rtf.h:236
#define rtfText
Definition: rtf.h:70
#define rtfLQuote
Definition: rtf.h:242
#define ERR(fmt,...)
Definition: debug.h:109
static void RTFUngetToken(RTF_Info *info)
Definition: reader.c:420
#define rtfDestination
Definition: rtf.h:99
BOOL bEmulateVersion10
Definition: editstr.h:352
#define rtfNoWidthNonJoiner
Definition: rtf.h:254
int rtfMajor
Definition: rtf.h:1110
#define rtfLine
Definition: rtf.h:231
static void RTFPutUnicodeChar(RTF_Info *info, int c)
Definition: reader.c:2624
#define rtfLTRMark
Definition: rtf.h:251
UINT cbSize
Definition: richedit.h:664
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:310
#define memset(x, y, z)
Definition: compat.h:39
#define rtfBullet
Definition: rtf.h:241
static void TextClass ( RTF_Info info)
static

Definition at line 2340 of file reader.c.

Referenced by BeginFile().

2341 {
2342  RTFPutCodePageChar(info, info->rtfMajor);
2343 }
static void RTFPutCodePageChar(RTF_Info *info, int c)
Definition: reader.c:2634
int rtfMajor
Definition: rtf.h:1110
WINE_DEFAULT_DEBUG_CHANNEL ( richedit  )
void WriterInit ( RTF_Info info)

Definition at line 2319 of file reader.c.

Referenced by ME_StreamIn().

2320 {
2321 }

Variable Documentation

RTFHashTableEntry rtfHashTable[RTF_KEY_COUNT *2]
static

Definition at line 2174 of file reader.c.

RTFKey rtfKey[]
static

Definition at line 1263 of file reader.c.