ReactOS  0.4.9-dev-728-g3d012a4
reader.c File Reference
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "wine/debug.h"
#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 2178 of file reader.c.

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

Typedef Documentation

typedef struct RTFKey RTFKey

Definition at line 1259 of file reader.c.

Function Documentation

int _RTFGetChar ( RTF_Info info)
static

Definition at line 95 of file reader.c.

Referenced by GetChar().

96 {
97  int ch;
98  ME_InStream *stream = info->stream;
99 
100  if (stream->dwSize <= stream->dwUsed)
101  {
102  ME_StreamInFill(stream);
103  /* if error, it's EOF */
104  if (stream->editstream->dwError)
105  return EOF;
106  /* if no bytes read, it's EOF */
107  if (stream->dwSize == 0)
108  return EOF;
109  }
110  ch = (unsigned char)stream->buffer[stream->dwUsed++];
111  if (!ch)
112  return EOF;
113  return ch;
114 }
ME_InStream * stream
Definition: rtf.h:1157
void ME_StreamInFill(ME_InStream *stream)
Definition: editor.c:1569
unsigned char
Definition: typeof.h:27
DWORD dwSize
Definition: editstr.h:371
if(!(yy_init))
Definition: macro.lex.yy.c:717
EDITSTREAM * editstream
Definition: editstr.h:370
Definition: parse.h:22
char buffer[STREAMIN_BUFFER_SIZE]
Definition: editstr.h:373
DWORD dwError
Definition: richedit.h:523
DWORD dwUsed
Definition: editstr.h:372
#define EOF
Definition: stdio.h:24
static void _RTFGetToken ( RTF_Info info)
static

Definition at line 454 of file reader.c.

Referenced by RTFGetToken().

455 {
456  if (info->rtfFormat == SF_TEXT)
457  {
458  info->rtfMajor = GetChar (info);
459  info->rtfMinor = 0;
460  info->rtfParam = rtfNoParam;
461  info->rtfTextBuf[info->rtfTextLen = 0] = '\0';
462  if (info->rtfMajor == EOF)
463  info->rtfClass = rtfEOF;
464  else
465  info->rtfClass = rtfText;
466  return;
467  }
468 
469  /* first check for pushed token from RTFUngetToken() */
470 
471  if (info->pushedClass >= 0)
472  {
473  info->rtfClass = info->pushedClass;
474  info->rtfMajor = info->pushedMajor;
475  info->rtfMinor = info->pushedMinor;
476  info->rtfParam = info->pushedParam;
477  lstrcpyA (info->rtfTextBuf, info->pushedTextBuf);
478  info->rtfTextLen = lstrlenA(info->rtfTextBuf);
479  info->pushedClass = -1;
480  return;
481  }
482 
483  /*
484  * Beyond this point, no token is ever seen twice, which is
485  * important, e.g., for making sure no "}" pops the font stack twice.
486  */
487 
488  _RTFGetToken2 (info);
489 }
int pushedParam
Definition: rtf.h:1140
static void _RTFGetToken2(RTF_Info *)
Definition: reader.c:554
int pushedMinor
Definition: rtf.h:1139
int pushedClass
Definition: rtf.h:1137
int rtfParam
Definition: rtf.h:1122
int rtfTextLen
Definition: rtf.h:1125
char * rtfTextBuf
Definition: rtf.h:1124
int pushedMajor
Definition: rtf.h:1138
int rtfMinor
Definition: rtf.h:1121
#define SF_TEXT
Definition: richedit.h:720
int rtfClass
Definition: rtf.h:1119
char * pushedTextBuf
Definition: rtf.h:1141
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
#define rtfText
Definition: rtf.h:80
static int GetChar(RTF_Info *)
Definition: reader.c:725
int rtfFormat
Definition: rtf.h:1123
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
int rtfMajor
Definition: rtf.h:1120
#define rtfNoParam
Definition: rtf.h:62
#define EOF
Definition: stdio.h:24
#define rtfEOF
Definition: rtf.h:82
static void _RTFGetToken2 ( RTF_Info info)
static

Definition at line 554 of file reader.c.

Referenced by _RTFGetToken().

555 {
556  int sign;
557  int c;
558 
559  /* initialize token vars */
560 
561  info->rtfClass = rtfUnknown;
562  info->rtfParam = rtfNoParam;
563  info->rtfTextBuf[info->rtfTextLen = 0] = '\0';
564 
565  /* get first character, which may be a pushback from previous token */
566 
567  if (info->pushedChar != EOF)
568  {
569  c = info->pushedChar;
570  info->rtfTextBuf[info->rtfTextLen++] = c;
571  info->rtfTextBuf[info->rtfTextLen] = '\0';
572  info->pushedChar = EOF;
573  }
574  else if ((c = GetChar (info)) == EOF)
575  {
576  info->rtfClass = rtfEOF;
577  return;
578  }
579 
580  if (c == '{')
581  {
582  info->rtfClass = rtfGroup;
583  info->rtfMajor = rtfBeginGroup;
584  return;
585  }
586  if (c == '}')
587  {
588  info->rtfClass = rtfGroup;
589  info->rtfMajor = rtfEndGroup;
590  return;
591  }
592  if (c != '\\')
593  {
594  /*
595  * Two possibilities here:
596  * 1) ASCII 9, effectively like \tab control symbol
597  * 2) literal text char
598  */
599  if (c == '\t') /* ASCII 9 */
600  {
601  info->rtfClass = rtfControl;
602  info->rtfMajor = rtfSpecialChar;
603  info->rtfMinor = rtfTab;
604  }
605  else
606  {
607  info->rtfClass = rtfText;
608  info->rtfMajor = c;
609  }
610  return;
611  }
612  if ((c = GetChar (info)) == EOF)
613  {
614  /* early eof, whoops (class is rtfUnknown) */
615  return;
616  }
617  if (!isalpha (c))
618  {
619  /*
620  * Three possibilities here:
621  * 1) hex encoded text char, e.g., \'d5, \'d3
622  * 2) special escaped text char, e.g., \{, \}
623  * 3) control symbol, e.g., \_, \-, \|, <10>
624  */
625  if (c == '\'') /* hex char */
626  {
627  int c2;
628 
629  if ((c = GetChar (info)) != EOF && (c2 = GetChar (info)) != EOF
630  && isxdigit(c) && isxdigit(c2))
631  {
632  info->rtfClass = rtfText;
633  info->rtfMajor = RTFCharToHex (c) * 16 + RTFCharToHex (c2);
634  return;
635  }
636  /* early eof, whoops */
637  info->rtfClass = rtfEOF;
638  info->stream->editstream->dwError = -14;
639  return;
640  }
641 
642  /* escaped char */
643  /*if (index (":{}\\", c) != NULL)*/ /* escaped char */
644  if (c == ':' || c == '{' || c == '}' || c == '\\')
645  {
646  info->rtfClass = rtfText;
647  info->rtfMajor = c;
648  return;
649  }
650 
651  /* control symbol */
652  Lookup (info, info->rtfTextBuf); /* sets class, major, minor */
653  return;
654  }
655  /* control word */
656  while (isalpha (c))
657  {
658  if ((c = GetChar (info)) == EOF)
659  break;
660  }
661 
662  /*
663  * At this point, the control word is all collected, so the
664  * major/minor numbers are determined before the parameter
665  * (if any) is scanned. There will be one too many characters
666  * in the buffer, though, so fix up before and restore after
667  * looking up.
668  */
669 
670  if (c != EOF)
671  info->rtfTextBuf[info->rtfTextLen-1] = '\0';
672  Lookup (info, info->rtfTextBuf); /* sets class, major, minor */
673  if (c != EOF)
674  info->rtfTextBuf[info->rtfTextLen-1] = c;
675 
676  /*
677  * Should be looking at first digit of parameter if there
678  * is one, unless it's negative. In that case, next char
679  * is '-', so need to gobble next char, and remember sign.
680  */
681 
682  sign = 1;
683  if (c == '-')
684  {
685  sign = -1;
686  c = GetChar (info);
687  }
688  if (c != EOF && isdigit (c))
689  {
690  info->rtfParam = 0;
691  while (isdigit (c)) /* gobble parameter */
692  {
693  info->rtfParam = info->rtfParam * 10 + c - '0';
694  if ((c = GetChar (info)) == EOF)
695  break;
696  }
697  info->rtfParam *= sign;
698  }
699  /*
700  * If control symbol delimiter was a blank, gobble it.
701  * Otherwise the character is first char of next token, so
702  * push it back for next call. In either case, delete the
703  * delimiter from the token buffer.
704  */
705  if (c != EOF)
706  {
707  if (c != ' ')
708  info->pushedChar = c;
709  info->rtfTextBuf[--info->rtfTextLen] = '\0';
710  }
711 }
static size_t double int int int * sign
Definition: printf.c:64
#define rtfUnknown
Definition: rtf.h:78
#define rtfBeginGroup
Definition: rtf.h:89
#define rtfEndGroup
Definition: rtf.h:90
ME_InStream * stream
Definition: rtf.h:1157
#define isalpha(c)
Definition: acclib.h:74
#define rtfSpecialChar
Definition: rtf.h:206
int rtfParam
Definition: rtf.h:1122
#define rtfGroup
Definition: rtf.h:79
int rtfTextLen
Definition: rtf.h:1125
char * rtfTextBuf
Definition: rtf.h:1124
static void Lookup(RTF_Info *, char *)
Definition: reader.c:2229
#define isdigit(c)
Definition: acclib.h:68
int rtfMinor
Definition: rtf.h:1121
int rtfClass
Definition: rtf.h:1119
int pushedChar
Definition: rtf.h:1135
#define rtfTab
Definition: rtf.h:246
#define rtfText
Definition: rtf.h:80
static int GetChar(RTF_Info *)
Definition: reader.c:725
#define rtfControl
Definition: rtf.h:81
EDITSTREAM * editstream
Definition: editstr.h:370
int rtfMajor
Definition: rtf.h:1120
DWORD dwError
Definition: richedit.h:523
#define rtfNoParam
Definition: rtf.h:62
#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:2298
#define rtfEOF
Definition: rtf.h:82
int BeginFile ( RTF_Info info)

Definition at line 2336 of file reader.c.

Referenced by ME_StreamIn().

2337 {
2338  /* install class callbacks */
2339 
2342 
2343  return (1);
2344 }
static void RTFSetClassCallback(RTF_Info *info, int class, RTFFuncPtr callback)
Definition: reader.c:191
static void ControlClass(RTF_Info *info)
Definition: reader.c:2358
#define rtfText
Definition: rtf.h:80
#define rtfControl
Definition: rtf.h:81
static void TextClass(RTF_Info *info)
Definition: reader.c:2351
static void CharAttr ( RTF_Info info)
static

Definition at line 2393 of file reader.c.

Referenced by ControlClass().

2394 {
2395  RTFFont *font;
2396 
2397  switch (info->rtfMinor)
2398  {
2399  case rtfFontNum:
2400  font = RTFGetFont(info, info->rtfParam);
2401  if (font)
2402  {
2403  if (info->ansiCodePage != CP_UTF8 && info->codePage != font->rtfFCodePage)
2404  {
2405  RTFFlushOutputBuffer(info);
2406  info->codePage = font->rtfFCodePage;
2407  }
2408  TRACE("font %d codepage %d\n", info->rtfParam, info->codePage);
2409  }
2410  else
2411  ERR( "unknown font %d\n", info->rtfParam);
2412  break;
2413  case rtfUnicodeLength:
2414  info->unicodeLength = info->rtfParam;
2415  break;
2416  }
2417 }
int codePage
Definition: rtf.h:1155
RTFFont * RTFGetFont(const RTF_Info *info, int num)
Definition: reader.c:1222
int rtfParam
Definition: rtf.h:1122
#define rtfUnicodeLength
Definition: rtf.h:599
Definition: rtf.h:959
#define CP_UTF8
Definition: nls.h:20
void RTFFlushOutputBuffer(RTF_Info *info)
Definition: reader.c:2627
int rtfMinor
Definition: rtf.h:1121
#define TRACE(s)
Definition: solgame.cpp:4
int unicodeLength
Definition: rtf.h:1154
int ansiCodePage
Definition: rtf.h:1150
int rtfFCodePage
Definition: rtf.h:968
#define ERR(fmt,...)
Definition: debug.h:109
#define rtfFontNum
Definition: rtf.h:573
static void CharSet ( RTF_Info info)
static

Definition at line 2421 of file reader.c.

Referenced by AddDlg_OnInitDialog(), ControlClass(), EditDlg_OnInitDialog(), and main().

2422 {
2423  if (info->ansiCodePage == CP_UTF8)
2424  return;
2425 
2426  switch (info->rtfMinor)
2427  {
2428  case rtfAnsiCharSet:
2429  info->ansiCodePage = 1252; /* Latin-1 */
2430  break;
2431  case rtfMacCharSet:
2432  info->ansiCodePage = 10000; /* MacRoman */
2433  break;
2434  case rtfPcCharSet:
2435  info->ansiCodePage = 437;
2436  break;
2437  case rtfPcaCharSet:
2438  info->ansiCodePage = 850;
2439  break;
2440  }
2441 }
#define rtfAnsiCharSet
Definition: rtf.h:101
#define rtfMacCharSet
Definition: rtf.h:102
#define CP_UTF8
Definition: nls.h:20
#define rtfPcCharSet
Definition: rtf.h:103
int rtfMinor
Definition: rtf.h:1121
int ansiCodePage
Definition: rtf.h:1150
#define rtfPcaCharSet
Definition: rtf.h:104
static void ControlClass ( RTF_Info info)
static

Definition at line 2358 of file reader.c.

Referenced by BeginFile().

2359 {
2360  switch (info->rtfMajor)
2361  {
2362  case rtfCharAttr:
2363  CharAttr(info);
2364  ME_RTFCharAttrHook(info);
2365  break;
2366  case rtfParAttr:
2367  ME_RTFParAttrHook(info);
2368  break;
2369  case rtfTblAttr:
2370  ME_RTFTblAttrHook(info);
2371  break;
2372  case rtfCharSet:
2373  CharSet(info);
2374  break;
2375  case rtfDefFont:
2376  DefFont(info);
2377  break;
2378  case rtfDestination:
2379  Destination (info);
2380  break;
2381  case rtfDocAttr:
2382  DocAttr(info);
2383  break;
2384  case rtfSpecialChar:
2385  SpecialChar (info);
2386  ME_RTFSpecialCharHook(info);
2387  break;
2388  }
2389 }
static void DefFont(RTF_Info *info)
Definition: reader.c:2458
static void Destination(RTF_Info *info)
Definition: reader.c:2450
#define rtfCharSet
Definition: rtf.h:100
#define rtfSpecialChar
Definition: rtf.h:206
static void CharSet(RTF_Info *info)
Definition: reader.c:2421
static void CharAttr(RTF_Info *info)
Definition: reader.c:2393
void ME_RTFCharAttrHook(RTF_Info *info)
Definition: editor.c:421
#define rtfParAttr
Definition: rtf.h:455
void ME_RTFParAttrHook(RTF_Info *info)
Definition: editor.c:552
#define rtfTblAttr
Definition: rtf.h:414
void ME_RTFSpecialCharHook(RTF_Info *info)
Definition: editor.c:944
void ME_RTFTblAttrHook(RTF_Info *info)
Definition: editor.c:870
#define rtfDefFont
Definition: rtf.h:98
#define rtfCharAttr
Definition: rtf.h:562
static void DocAttr(RTF_Info *info)
Definition: reader.c:2466
#define rtfDestination
Definition: rtf.h:109
int rtfMajor
Definition: rtf.h:1120
#define rtfDocAttr
Definition: rtf.h:276
static void SpecialChar(RTF_Info *info)
Definition: reader.c:2482
static void DefFont ( RTF_Info info)
static

Definition at line 2458 of file reader.c.

Referenced by ControlClass().

2459 {
2460  TRACE("%d\n", info->rtfParam);
2461  info->defFont = info->rtfParam;
2462 }
int rtfParam
Definition: rtf.h:1122
#define TRACE(s)
Definition: solgame.cpp:4
int defFont
Definition: rtf.h:1151
static void Destination ( RTF_Info info)
static

Definition at line 2450 of file reader.c.

Referenced by ControlClass().

2451 {
2452  if (!RTFGetDestinationCallback(info, info->rtfMinor))
2453  RTFSkipGroup (info);
2454 }
void RTFSkipGroup(RTF_Info *info)
Definition: reader.c:354
int rtfMinor
Definition: rtf.h:1121
static RTFFuncPtr RTFGetDestinationCallback(const RTF_Info *info, int dest)
Definition: reader.c:288
static void DocAttr ( RTF_Info info)
static

Definition at line 2466 of file reader.c.

Referenced by ControlClass().

2467 {
2468  TRACE("minor %d, param %d\n", info->rtfMinor, info->rtfParam);
2469 
2470  switch (info->rtfMinor)
2471  {
2472  case rtfAnsiCodePage:
2473  info->codePage = info->ansiCodePage = info->rtfParam;
2474  break;
2475  case rtfUTF8RTF:
2476  info->codePage = info->ansiCodePage = CP_UTF8;
2477  break;
2478  }
2479 }
int codePage
Definition: rtf.h:1155
#define rtfAnsiCodePage
Definition: rtf.h:355
#define rtfUTF8RTF
Definition: rtf.h:356
int rtfParam
Definition: rtf.h:1122
#define CP_UTF8
Definition: nls.h:20
int rtfMinor
Definition: rtf.h:1121
#define TRACE(s)
Definition: solgame.cpp:4
int ansiCodePage
Definition: rtf.h:1150
static int GetChar ( RTF_Info info)
static

Definition at line 725 of file reader.c.

Referenced by _RTFGetToken(), and _RTFGetToken2().

726 {
727  int c;
728  BOOL oldBumpLine;
729 
730  if ((c = _RTFGetChar(info)) != EOF)
731  {
732  info->rtfTextBuf[info->rtfTextLen++] = c;
733  info->rtfTextBuf[info->rtfTextLen] = '\0';
734  }
735  if (info->prevChar == EOF)
736  info->bumpLine = TRUE;
737  oldBumpLine = info->bumpLine; /* TRUE if prev char was line ending */
738  info->bumpLine = FALSE;
739  if (c == '\r')
740  info->bumpLine = TRUE;
741  else if (c == '\n')
742  {
743  info->bumpLine = TRUE;
744  if (info->prevChar == '\r') /* oops, previous \r wasn't */
745  oldBumpLine = FALSE; /* really a line ending */
746  }
747  ++info->rtfLinePos;
748  if (oldBumpLine) /* were we supposed to increment the */
749  { /* line count on this char? */
750  ++info->rtfLineNum;
751  info->rtfLinePos = 1;
752  }
753  info->prevChar = c;
754  return (c);
755 }
#define TRUE
Definition: types.h:120
int rtfLineNum
Definition: rtf.h:1127
int rtfTextLen
Definition: rtf.h:1125
char * rtfTextBuf
Definition: rtf.h:1124
#define FALSE
Definition: types.h:117
static int _RTFGetChar(RTF_Info *)
Definition: reader.c:95
BOOL bumpLine
Definition: rtf.h:1144
unsigned int BOOL
Definition: ntddk_ex.h:94
int prevChar
Definition: rtf.h:1143
int rtfLinePos
Definition: rtf.h:1128
#define EOF
Definition: stdio.h:24
#define c
Definition: ke_i.h:80
static void Lookup ( RTF_Info info,
char s 
)
static

Definition at line 2229 of file reader.c.

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

2230 {
2231  RTFKey *rp;
2232  int hash;
2234  int i;
2235 
2236  ++s; /* skip over the leading \ character */
2237  hash = Hash (s);
2238  entry = &rtfHashTable[hash % (RTF_KEY_COUNT * 2)];
2239  for (i = 0; i < entry->count; i++)
2240  {
2241  rp = entry->value[i];
2242  if (hash == rp->rtfKHash && strcmp (s, rp->rtfKStr) == 0)
2243  {
2244  info->rtfClass = rtfControl;
2245  info->rtfMajor = rp->rtfKMajor;
2246  info->rtfMinor = rp->rtfKMinor;
2247  return;
2248  }
2249  }
2250  info->rtfClass = rtfUnknown;
2251 }
static int Hash(const char *)
Definition: reader.c:2258
#define rtfUnknown
Definition: rtf.h:78
int rtfKMinor
Definition: reader.c:1264
RTFKey ** value
Definition: reader.c:2182
uint8_t entry
Definition: isohybrid.c:63
#define RTF_KEY_COUNT
Definition: reader.c:2178
GLenum GLclampf GLint i
Definition: glfuncs.h:14
int hash
Definition: main.c:58
int rtfMinor
Definition: rtf.h:1121
int rtfClass
Definition: rtf.h:1119
#define rtfControl
Definition: rtf.h:81
GLdouble s
Definition: gl.h:2039
int rtfKMajor
Definition: reader.c:1263
int rtfMajor
Definition: rtf.h:1120
const char * rtfKStr
Definition: reader.c:1265
static RTFHashTableEntry rtfHashTable[RTF_KEY_COUNT *2]
Definition: reader.c:2185
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int rtfKHash
Definition: reader.c:1266
void LookupCleanup ( void  )

Definition at line 2211 of file reader.c.

Referenced by DllMain().

2212 {
2213  unsigned int i;
2214 
2215  for (i=0; i<RTF_KEY_COUNT*2; i++)
2216  {
2218  rtfHashTable[i].value = NULL;
2219  rtfHashTable[i].count = 0;
2220  }
2221 }
Definition: get.c:139
RTFKey ** value
Definition: reader.c:2182
#define RTF_KEY_COUNT
Definition: reader.c:2178
GLenum GLclampf GLint i
Definition: glfuncs.h:14
smooth NULL
Definition: ftsmooth.c:416
static RTFHashTableEntry rtfHashTable[RTF_KEY_COUNT *2]
Definition: reader.c:2185
static BOOL heap_free(void *mem)
Definition: appwiz.h:71
void LookupInit ( void  )

Definition at line 2192 of file reader.c.

Referenced by DllMain().

2193 {
2194  RTFKey *rp;
2195 
2196  memset(rtfHashTable, 0, sizeof rtfHashTable);
2197  for (rp = rtfKey; rp->rtfKStr != NULL; rp++)
2198  {
2199  int index;
2200 
2201  rp->rtfKHash = Hash (rp->rtfKStr);
2202  index = rp->rtfKHash % (RTF_KEY_COUNT * 2);
2203  if (!rtfHashTable[index].count)
2204  rtfHashTable[index].value = heap_alloc(sizeof(RTFKey *));
2205  else
2206  rtfHashTable[index].value = heap_realloc(rtfHashTable[index].value, sizeof(RTFKey *) * (rtfHashTable[index].count + 1));
2208  }
2209 }
static int Hash(const char *)
Definition: reader.c:2258
Definition: get.c:139
RTFKey ** value
Definition: reader.c:2182
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:66
static void * heap_alloc(size_t len)
Definition: appwiz.h:61
#define RTF_KEY_COUNT
Definition: reader.c:2178
smooth NULL
Definition: ftsmooth.c:416
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define index(s, c)
Definition: various.h:29
static RTFKey rtfKey[]
Definition: reader.c:1274
const char * rtfKStr
Definition: reader.c:1265
static RTFHashTableEntry rtfHashTable[RTF_KEY_COUNT *2]
Definition: reader.c:2185
int rtfKHash
Definition: reader.c:1266
#define memset(x, y, z)
Definition: compat.h:39
static void ReadColorTbl ( RTF_Info info)
static

Definition at line 965 of file reader.c.

Referenced by RTFInit().

966 {
967  RTFColor *cp;
968  int cnum = 0;
969  int group_level = 1;
970 
971  for (;;)
972  {
973  RTFGetToken (info);
974  if (info->rtfClass == rtfEOF)
975  break;
976  if (RTFCheckCM (info, rtfGroup, rtfEndGroup))
977  {
978  group_level--;
979  if (!group_level)
980  break;
981  continue;
982  }
983  else if (RTFCheckCM(info, rtfGroup, rtfBeginGroup))
984  {
985  group_level++;
986  continue;
987  }
988 
989  cp = New (RTFColor);
990  if (cp == NULL) {
991  ERR ("cannot allocate color entry\n");
992  break;
993  }
994  cp->rtfCNum = cnum++;
995  cp->rtfNextColor = info->colorList;
996  info->colorList = cp;
997  if (!RTFCheckCM (info, rtfControl, rtfColorName))
998  cp->rtfCRed = cp->rtfCGreen = cp->rtfCBlue = -1;
999  else {
1000  cp->rtfCRed = cp->rtfCGreen = cp->rtfCBlue = 0;
1001  do {
1002  switch (info->rtfMinor)
1003  {
1004  case rtfRed: cp->rtfCRed = info->rtfParam & 0xFF; break;
1005  case rtfGreen: cp->rtfCGreen = info->rtfParam & 0xFF; break;
1006  case rtfBlue: cp->rtfCBlue = info->rtfParam & 0xFF; break;
1007  }
1008  RTFGetToken (info);
1009  } while (RTFCheckCM (info, rtfControl, rtfColorName));
1010  }
1011  if (info->rtfClass == rtfEOF)
1012  break;
1013  if (!RTFCheckCM (info, rtfText, ';'))
1014  ERR ("malformed entry\n");
1015  }
1016  RTFRouteToken (info); /* feed "}" back to router */
1017 }
Definition: rtf.h:978
#define rtfBeginGroup
Definition: rtf.h:89
#define rtfEndGroup
Definition: rtf.h:90
#define rtfRed
Definition: rtf.h:202
#define New(t)
Definition: rtf.h:1086
int rtfParam
Definition: rtf.h:1122
int rtfCRed
Definition: rtf.h:981
#define rtfGroup
Definition: rtf.h:79
RTFColor * colorList
Definition: rtf.h:1148
int RTFCheckCM(const RTF_Info *info, int class, int major)
Definition: reader.c:2277
int rtfCGreen
Definition: rtf.h:982
smooth NULL
Definition: ftsmooth.c:416
int rtfMinor
Definition: rtf.h:1121
int rtfCBlue
Definition: rtf.h:983
int rtfClass
Definition: rtf.h:1119
int RTFGetToken(RTF_Info *info)
Definition: reader.c:406
#define rtfBlue
Definition: rtf.h:204
#define rtfText
Definition: rtf.h:80
#define rtfControl
Definition: rtf.h:81
#define rtfGreen
Definition: rtf.h:203
#define ERR(fmt,...)
Definition: debug.h:109
int rtfCNum
Definition: rtf.h:980
POINT cp
Definition: magnifier.c:58
#define rtfColorName
Definition: rtf.h:201
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:321
RTFColor * rtfNextColor
Definition: rtf.h:984
#define rtfEOF
Definition: rtf.h:82
static void ReadFontTbl ( RTF_Info info)
static

Definition at line 786 of file reader.c.

Referenced by RTFInit().

787 {
788  RTFFont *fp = NULL;
789  char buf[rtfBufSiz], *bp;
790  int old = -1;
791 
792  for (;;)
793  {
794  RTFGetToken (info);
795  if (info->rtfClass == rtfEOF)
796  break;
797  if (RTFCheckCM (info, rtfGroup, rtfEndGroup))
798  break;
799  if (old < 0) /* first entry - determine tbl type */
800  {
802  old = 1; /* no brace */
803  else if (RTFCheckCM (info, rtfGroup, rtfBeginGroup))
804  old = 0; /* brace */
805  else /* can't tell! */
806  ERR ("cannot determine format\n");
807  }
808  if (old == 0) /* need to find "{" here */
809  {
810  if (!RTFCheckCM (info, rtfGroup, rtfBeginGroup))
811  ERR ("missing \"{\"\n");
812  RTFGetToken (info); /* yes, skip to next token */
813  if (info->rtfClass == rtfEOF)
814  break;
815  }
816  fp = New (RTFFont);
817  if (fp == NULL) {
818  ERR ("cannot allocate font entry\n");
819  break;
820  }
821 
822  fp->rtfNextFont = info->fontList;
823  info->fontList = fp;
824 
825  fp->rtfFName = NULL;
826  fp->rtfFAltName = NULL;
827  fp->rtfFNum = -1;
828  fp->rtfFFamily = FF_DONTCARE;
829  fp->rtfFCharSet = DEFAULT_CHARSET; /* 1 */
830  fp->rtfFPitch = DEFAULT_PITCH;
831  fp->rtfFType = 0;
832  fp->rtfFCodePage = CP_ACP;
833 
834  while (info->rtfClass != rtfEOF
835  && !RTFCheckCM (info, rtfText, ';')
836  && !RTFCheckCM (info, rtfGroup, rtfEndGroup))
837  {
838  if (info->rtfClass == rtfControl)
839  {
840  switch (info->rtfMajor)
841  {
842  default:
843  /* ignore token but announce it */
844  WARN ("unknown token \"%s\"\n",
845  info->rtfTextBuf);
846  break;
847  case rtfFontFamily:
848  fp->rtfFFamily = info->rtfMinor;
849  break;
850  case rtfCharAttr:
851  switch (info->rtfMinor)
852  {
853  default:
854  break; /* ignore unknown? */
855  case rtfFontNum:
856  fp->rtfFNum = info->rtfParam;
857  break;
858  }
859  break;
860  case rtfFontAttr:
861  switch (info->rtfMinor)
862  {
863  default:
864  break; /* ignore unknown? */
865  case rtfFontCharSet:
866  fp->rtfFCharSet = info->rtfParam;
867  if (!fp->rtfFCodePage)
868  fp->rtfFCodePage = RTFCharSetToCodePage(info, info->rtfParam);
869  break;
870  case rtfFontPitch:
871  fp->rtfFPitch = info->rtfParam;
872  break;
873  case rtfFontCodePage:
874  fp->rtfFCodePage = info->rtfParam;
875  break;
876  case rtfFTypeNil:
877  case rtfFTypeTrueType:
878  fp->rtfFType = info->rtfParam;
879  break;
880  }
881  break;
882  }
883  }
884  else if (RTFCheckCM (info, rtfGroup, rtfBeginGroup)) /* dest */
885  {
886  RTFSkipGroup (info); /* ignore for now */
887  }
888  else if (info->rtfClass == rtfText) /* font name */
889  {
890  bp = buf;
891  while (info->rtfClass == rtfText
892  && !RTFCheckCM (info, rtfText, ';'))
893  {
894  *bp++ = info->rtfMajor;
895  RTFGetToken (info);
896  }
897 
898  /* FIX: in some cases the <fontinfo> isn't finished with a semi-column */
899  if(RTFCheckCM (info, rtfGroup, rtfEndGroup))
900  {
901  RTFUngetToken (info);
902  }
903  *bp = '\0';
904  fp->rtfFName = RTFStrSave (buf);
905  if (fp->rtfFName == NULL)
906  ERR ("cannot allocate font name\n");
907  /* already have next token; don't read one */
908  /* at bottom of loop */
909  continue;
910  }
911  else
912  {
913  /* ignore token but announce it */
914  WARN ("unknown token \"%s\"\n", info->rtfTextBuf);
915  }
916  RTFGetToken (info);
917  if (info->rtfClass == rtfEOF)
918  break;
919  }
920  if (info->rtfClass == rtfEOF)
921  break;
922  if (old == 0) /* need to see "}" here */
923  {
924  RTFGetToken (info);
925  if (!RTFCheckCM (info, rtfGroup, rtfEndGroup))
926  ERR ("missing \"}\"\n");
927  if (info->rtfClass == rtfEOF)
928  break;
929  }
930 
931  /* Apply the real properties of the default font */
932  if (fp->rtfFNum == info->defFont)
933  {
934  if (info->ansiCodePage != CP_UTF8)
935  info->codePage = fp->rtfFCodePage;
936  TRACE("default font codepage %d\n", info->codePage);
937  }
938  }
939  if (!fp || (fp->rtfFNum == -1))
940  ERR("missing font number\n");
941 /*
942  * Could check other pieces of structure here, too, I suppose.
943  */
944  RTFRouteToken (info); /* feed "}" back to router */
945 
946  /* Set default font */
947  info->rtfClass = rtfControl;
948  info->rtfMajor = rtfCharAttr;
949  info->rtfMinor = rtfFontNum;
950  info->rtfParam = info->defFont;
951  lstrcpyA(info->rtfTextBuf, "f");
952  RTFUngetToken(info);
953 }
int codePage
Definition: rtf.h:1155
int rtfFFamily
Definition: rtf.h:964
int rtfFCharSet
Definition: rtf.h:965
#define FF_DONTCARE
Definition: wingdi.h:446
#define rtfBeginGroup
Definition: rtf.h:89
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define rtfEndGroup
Definition: rtf.h:90
static char * RTFStrSave(const char *s)
Definition: reader.c:81
#define CP_ACP
Definition: compat.h:99
#define WARN(fmt,...)
Definition: debug.h:111
char * rtfFAltName
Definition: rtf.h:962
char * rtfFName
Definition: rtf.h:961
int rtfFType
Definition: rtf.h:967
#define rtfFontCharSet
Definition: rtf.h:735
#define New(t)
Definition: rtf.h:1086
int rtfParam
Definition: rtf.h:1122
#define rtfGroup
Definition: rtf.h:79
#define DEFAULT_CHARSET
Definition: wingdi.h:382
Definition: rtf.h:959
void RTFSkipGroup(RTF_Info *info)
Definition: reader.c:354
int RTFCharSetToCodePage(RTF_Info *info, int charset)
Definition: reader.c:493
#define rtfFTypeNil
Definition: rtf.h:738
char * rtfTextBuf
Definition: rtf.h:1124
#define CP_UTF8
Definition: nls.h:20
#define rtfFontFamily
Definition: rtf.h:191
int RTFCheckCM(const RTF_Info *info, int class, int major)
Definition: reader.c:2277
#define rtfBufSiz
Definition: rtf.h:30
smooth NULL
Definition: ftsmooth.c:416
#define rtfFontPitch
Definition: rtf.h:736
int rtfMinor
Definition: rtf.h:1121
RTFFont * fontList
Definition: rtf.h:1147
#define TRACE(s)
Definition: solgame.cpp:4
int rtfClass
Definition: rtf.h:1119
#define DEFAULT_PITCH
Definition: wingdi.h:441
int RTFGetToken(RTF_Info *info)
Definition: reader.c:406
int defFont
Definition: rtf.h:1151
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
#define rtfText
Definition: rtf.h:80
#define rtfCharAttr
Definition: rtf.h:562
#define rtfControl
Definition: rtf.h:81
int ansiCodePage
Definition: rtf.h:1150
int rtfFCodePage
Definition: rtf.h:968
#define ERR(fmt,...)
Definition: debug.h:109
#define rtfFontAttr
Definition: rtf.h:734
static void RTFUngetToken(RTF_Info *info)
Definition: reader.c:431
int rtfMajor
Definition: rtf.h:1120
int RTFCheckCMM(const RTF_Info *info, int class, int major, int minor)
Definition: reader.c:2283
#define rtfFTypeTrueType
Definition: rtf.h:739
int rtfFNum
Definition: rtf.h:963
RTFFont * rtfNextFont
Definition: rtf.h:969
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:321
#define rtfFontNum
Definition: rtf.h:573
int rtfFPitch
Definition: rtf.h:966
#define rtfFontCodePage
Definition: rtf.h:737
#define rtfEOF
Definition: rtf.h:82
static void ReadInfoGroup ( RTF_Info info)
static

Definition at line 1194 of file reader.c.

Referenced by RTFInit().

1195 {
1196  RTFSkipGroup (info);
1197  RTFRouteToken (info); /* feed "}" back to router */
1198 }
void RTFSkipGroup(RTF_Info *info)
Definition: reader.c:354
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:321
static void ReadObjGroup ( RTF_Info info)
static

Definition at line 1208 of file reader.c.

Referenced by RTFInit().

1209 {
1210  RTFSkipGroup (info);
1211  RTFRouteToken (info); /* feed "}" back to router */
1212 }
void RTFSkipGroup(RTF_Info *info)
Definition: reader.c:354
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:321
static void ReadPictGroup ( RTF_Info info)
static

Definition at line 1201 of file reader.c.

Referenced by RTFInit().

1202 {
1203  RTFSkipGroup (info);
1204  RTFRouteToken (info); /* feed "}" back to router */
1205 }
void RTFSkipGroup(RTF_Info *info)
Definition: reader.c:354
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:321
static void ReadStyleSheet ( RTF_Info info)
static

Definition at line 1025 of file reader.c.

Referenced by RTFInit().

1026 {
1027  RTFStyle *sp;
1028  RTFStyleElt *sep, *sepLast;
1029  char buf[rtfBufSiz], *bp;
1030  int real_style;
1031 
1032  for (;;)
1033  {
1034  RTFGetToken (info);
1035  if (info->rtfClass == rtfEOF)
1036  break;
1037  if (RTFCheckCM (info, rtfGroup, rtfEndGroup))
1038  break;
1039  sp = New (RTFStyle);
1040  if (sp == NULL) {
1041  ERR ("cannot allocate stylesheet entry\n");
1042  break;
1043  }
1044  sp->rtfSName = NULL;
1045  sp->rtfSNum = -1;
1046  sp->rtfSType = rtfParStyle;
1047  sp->rtfSAdditive = 0;
1048  sp->rtfSBasedOn = rtfNoStyleNum;
1049  sp->rtfSNextPar = -1;
1050  sp->rtfSSEList = sepLast = NULL;
1051  sp->rtfNextStyle = info->styleList;
1052  sp->rtfExpanding = 0;
1053  info->styleList = sp;
1054  if (!RTFCheckCM (info, rtfGroup, rtfBeginGroup))
1055  ERR ("missing \"{\"\n");
1056  real_style = TRUE;
1057  for (;;)
1058  {
1059  RTFGetToken (info);
1060  if (info->rtfClass == rtfEOF
1061  || RTFCheckCM (info, rtfText, ';'))
1062  break;
1063  if (info->rtfClass == rtfControl)
1064  {
1065  if (RTFCheckMM (info, rtfSpecialChar, rtfOptDest)) {
1066  RTFGetToken(info);
1067  ERR("skipping optional destination\n");
1068  RTFSkipGroup(info);
1069  info->rtfClass = rtfGroup;
1070  info->rtfMajor = rtfEndGroup;
1071  real_style = FALSE;
1072  break; /* ignore "\*" */
1073  }
1074  if (RTFCheckMM (info, rtfParAttr, rtfStyleNum))
1075  {
1076  sp->rtfSNum = info->rtfParam;
1077  sp->rtfSType = rtfParStyle;
1078  continue;
1079  }
1080  if (RTFCheckMM (info, rtfCharAttr, rtfCharStyleNum))
1081  {
1082  sp->rtfSNum = info->rtfParam;
1083  sp->rtfSType = rtfCharStyle;
1084  continue;
1085  }
1086  if (RTFCheckMM (info, rtfSectAttr, rtfSectStyleNum))
1087  {
1088  sp->rtfSNum = info->rtfParam;
1089  sp->rtfSType = rtfSectStyle;
1090  continue;
1091  }
1092  if (RTFCheckMM (info, rtfStyleAttr, rtfBasedOn))
1093  {
1094  sp->rtfSBasedOn = info->rtfParam;
1095  continue;
1096  }
1097  if (RTFCheckMM (info, rtfStyleAttr, rtfAdditive))
1098  {
1099  sp->rtfSAdditive = 1;
1100  continue;
1101  }
1102  if (RTFCheckMM (info, rtfStyleAttr, rtfNext))
1103  {
1104  sp->rtfSNextPar = info->rtfParam;
1105  continue;
1106  }
1107  sep = New (RTFStyleElt);
1108  if (sep == NULL)
1109  {
1110  ERR ("cannot allocate style element\n");
1111  break;
1112  }
1113  sep->rtfSEClass = info->rtfClass;
1114  sep->rtfSEMajor = info->rtfMajor;
1115  sep->rtfSEMinor = info->rtfMinor;
1116  sep->rtfSEParam = info->rtfParam;
1117  sep->rtfSEText = RTFStrSave (info->rtfTextBuf);
1118  if (sep->rtfSEText == NULL)
1119  ERR ("cannot allocate style element text\n");
1120  if (sepLast == NULL)
1121  sp->rtfSSEList = sep; /* first element */
1122  else /* add to end */
1123  sepLast->rtfNextSE = sep;
1124  sep->rtfNextSE = NULL;
1125  sepLast = sep;
1126  }
1127  else if (RTFCheckCM (info, rtfGroup, rtfBeginGroup))
1128  {
1129  /*
1130  * This passes over "{\*\keycode ... }, among
1131  * other things. A temporary (perhaps) hack.
1132  */
1133  ERR("skipping begin\n");
1134  RTFSkipGroup (info);
1135  continue;
1136  }
1137  else if (info->rtfClass == rtfText) /* style name */
1138  {
1139  bp = buf;
1140  while (info->rtfClass == rtfText)
1141  {
1142  if (info->rtfMajor == ';')
1143  {
1144  /* put back for "for" loop */
1145  RTFUngetToken (info);
1146  break;
1147  }
1148  *bp++ = info->rtfMajor;
1149  RTFGetToken (info);
1150  }
1151  *bp = '\0';
1152  sp->rtfSName = RTFStrSave (buf);
1153  if (sp->rtfSName == NULL)
1154  ERR ("cannot allocate style name\n");
1155  }
1156  else /* unrecognized */
1157  {
1158  /* ignore token but announce it */
1159  WARN ("unknown token \"%s\"\n", info->rtfTextBuf);
1160  }
1161  }
1162  if (real_style) {
1163  RTFGetToken (info);
1164  if (!RTFCheckCM (info, rtfGroup, rtfEndGroup))
1165  ERR ("missing \"}\"\n");
1166  /*
1167  * Check over the style structure. A name is a must.
1168  * If no style number was specified, check whether it's the
1169  * Normal style (in which case it's given style number
1170  * rtfNormalStyleNum). Note that some "normal" style names
1171  * just begin with "Normal" and can have other stuff following,
1172  * e.g., "Normal,Times 10 point". Ugh.
1173  *
1174  * Some German RTF writers use "Standard" instead of "Normal".
1175  */
1176  if (sp->rtfSName == NULL)
1177  ERR ("missing style name\n");
1178  if (sp->rtfSNum < 0)
1179  {
1180  if (strncmp (buf, "Normal", 6) != 0
1181  && strncmp (buf, "Standard", 8) != 0)
1182  ERR ("missing style number\n");
1183  sp->rtfSNum = rtfNormalStyleNum;
1184  }
1185  if (sp->rtfSNextPar == -1) /* if \snext not given, */
1186  sp->rtfSNextPar = sp->rtfSNum; /* next is itself */
1187  }
1188  /* otherwise we're just dealing with fake end group from skipped group */
1189  }
1190  RTFRouteToken (info); /* feed "}" back to router */
1191 }
int rtfSEParam
Definition: rtf.h:1007
#define TRUE
Definition: types.h:120
int rtfSEMinor
Definition: rtf.h:1006
#define rtfBeginGroup
Definition: rtf.h:89
RTFStyle * rtfNextStyle
Definition: rtf.h:998
int rtfExpanding
Definition: rtf.h:997
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define rtfNormalStyleNum
Definition: rtf.h:71
#define rtfEndGroup
Definition: rtf.h:90
static char * RTFStrSave(const char *s)
Definition: reader.c:81
RTFStyleElt * rtfNextSE
Definition: rtf.h:1009
#define WARN(fmt,...)
Definition: debug.h:111
#define New(t)
Definition: rtf.h:1086
int rtfSNextPar
Definition: rtf.h:995
#define rtfSectAttr
Definition: rtf.h:358
#define rtfSpecialChar
Definition: rtf.h:206
int rtfSBasedOn
Definition: rtf.h:994
int rtfParam
Definition: rtf.h:1122
int rtfSAdditive
Definition: rtf.h:992
int rtfSType
Definition: rtf.h:991
#define rtfGroup
Definition: rtf.h:79
void RTFSkipGroup(RTF_Info *info)
Definition: reader.c:354
int rtfSNum
Definition: rtf.h:993
char * rtfTextBuf
Definition: rtf.h:1124
#define rtfCharStyle
Definition: rtf.h:943
#define FALSE
Definition: types.h:117
#define rtfSectStyle
Definition: rtf.h:944
char * rtfSName
Definition: rtf.h:990
int RTFCheckCM(const RTF_Info *info, int class, int major)
Definition: reader.c:2277
#define rtfParAttr
Definition: rtf.h:455
#define rtfBufSiz
Definition: rtf.h:30
smooth NULL
Definition: ftsmooth.c:416
int rtfMinor
Definition: rtf.h:1121
#define rtfOptDest
Definition: rtf.h:260
int rtfClass
Definition: rtf.h:1119
int rtfSEClass
Definition: rtf.h:1004
int RTFGetToken(RTF_Info *info)
Definition: reader.c:406
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
int rtfSEMajor
Definition: rtf.h:1005
#define rtfCharStyleNum
Definition: rtf.h:595
#define rtfText
Definition: rtf.h:80
#define rtfStyleNum
Definition: rtf.h:457
#define rtfCharAttr
Definition: rtf.h:562
#define rtfControl
Definition: rtf.h:81
int RTFCheckMM(const RTF_Info *info, int major, int minor)
Definition: reader.c:2289
#define rtfParStyle
Definition: rtf.h:942
#define ERR(fmt,...)
Definition: debug.h:109
static void RTFUngetToken(RTF_Info *info)
Definition: reader.c:431
int rtfMajor
Definition: rtf.h:1120
#define rtfNext
Definition: rtf.h:274
char * rtfSEText
Definition: rtf.h:1008
#define rtfNoStyleNum
Definition: rtf.h:70
static const WCHAR sp[]
Definition: suminfo.c:288
#define rtfAdditive
Definition: rtf.h:272
#define rtfStyleAttr
Definition: rtf.h:271
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:321
RTFStyleElt * rtfSSEList
Definition: rtf.h:996
#define rtfBasedOn
Definition: rtf.h:273
Definition: rtf.h:988
RTFStyle * styleList
Definition: rtf.h:1149
#define rtfSectStyleNum
Definition: rtf.h:363
#define rtfEOF
Definition: rtf.h:82
int RTFCharSetToCodePage ( RTF_Info info,
int  charset 
)

Definition at line 493 of file reader.c.

Referenced by ME_StreamOutRTFCharProps(), and ReadFontTbl().

494 {
495  switch (charset)
496  {
497  case ANSI_CHARSET:
498  return 1252;
499  case DEFAULT_CHARSET:
500  return CP_ACP;
501  case SYMBOL_CHARSET:
502  return CP_SYMBOL;
503  case MAC_CHARSET:
504  return CP_MACCP;
505  case SHIFTJIS_CHARSET:
506  return 932;
507  case HANGEUL_CHARSET:
508  return 949;
509  case JOHAB_CHARSET:
510  return 1361;
511  case GB2312_CHARSET:
512  return 936;
513  case CHINESEBIG5_CHARSET:
514  return 950;
515  case GREEK_CHARSET:
516  return 1253;
517  case TURKISH_CHARSET:
518  return 1254;
519  case VIETNAMESE_CHARSET:
520  return 1258;
521  case HEBREW_CHARSET:
522  return 1255;
523  case ARABIC_CHARSET:
524  return 1256;
525  case BALTIC_CHARSET:
526  return 1257;
527  case RUSSIAN_CHARSET:
528  return 1251;
529  case THAI_CHARSET:
530  return 874;
531  case EASTEUROPE_CHARSET:
532  return 1250;
533  case OEM_CHARSET:
534  return CP_OEMCP;
535  default:
536  {
537  CHARSETINFO csi;
538  DWORD n = charset;
539 
540  /* FIXME: TranslateCharsetInfo does not work as good as it
541  * should, so let's use it only when all else fails */
542  if (!TranslateCharsetInfo(&n, &csi, TCI_SRCCHARSET))
543  ERR("unknown charset %d\n", charset);
544  else
545  return csi.ciACP;
546  }
547  }
548  return 0;
549 }
#define MAC_CHARSET
Definition: wingdi.h:401
CFF_Charset charset
Definition: cffcmap.c:138
#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 2298 of file reader.c.

Referenced by _RTFGetToken2(), and read_hex_data().

2299 {
2300  if (isupper (c))
2301  c = tolower (c);
2302  if (isdigit (c))
2303  return (c - '0'); /* '0'..'9' */
2304  return (c - 'a' + 10); /* 'a'..'f' */
2305 }
#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 2277 of file reader.c.

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

2278 {
2279  return (info->rtfClass == class && info->rtfMajor == major);
2280 }
int rtfClass
Definition: rtf.h:1119
int rtfMajor
Definition: rtf.h:1120
#define major(rdev)
Definition: propsheet.cpp:818
int RTFCheckCMM ( const RTF_Info info,
int  class,
int  major,
int  minor 
)

Definition at line 2283 of file reader.c.

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

2284 {
2285  return (info->rtfClass == class && info->rtfMajor == major && info->rtfMinor == minor);
2286 }
int rtfMinor
Definition: rtf.h:1121
int rtfClass
Definition: rtf.h:1119
int rtfMajor
Definition: rtf.h:1120
#define major(rdev)
Definition: propsheet.cpp:818
#define minor(rdev)
Definition: propsheet.cpp:819
int RTFCheckMM ( const RTF_Info info,
int  major,
int  minor 
)

Definition at line 2289 of file reader.c.

Referenced by ME_RTFReadPictGroup(), and ReadStyleSheet().

2290 {
2291  return (info->rtfMajor == major && info->rtfMinor == minor);
2292 }
int rtfMinor
Definition: rtf.h:1121
int rtfMajor
Definition: rtf.h:1120
#define major(rdev)
Definition: propsheet.cpp:818
#define minor(rdev)
Definition: propsheet.cpp:819
void RTFDestroy ( RTF_Info info)

Definition at line 161 of file reader.c.

Referenced by ME_StreamIn().

162 {
163  if (info->rtfTextBuf)
164  {
165  heap_free(info->rtfTextBuf);
166  heap_free(info->pushedTextBuf);
167  }
168  RTFDestroyAttrs(info);
169  heap_free(info->cpOutputBuffer);
170  while (info->tableDef)
171  {
172  RTFTable *tableDef = info->tableDef;
173  info->tableDef = tableDef->parent;
174  heap_free(tableDef);
175  }
176 }
static void RTFDestroyAttrs(RTF_Info *info)
Definition: reader.c:122
RTFTable * tableDef
Definition: rtf.h:1179
char * rtfTextBuf
Definition: rtf.h:1124
RTFTable * parent
Definition: rtf.h:1044
char * pushedTextBuf
Definition: rtf.h:1141
char * cpOutputBuffer
Definition: rtf.h:1173
Definition: rtf.h:1025
static BOOL heap_free(void *mem)
Definition: appwiz.h:71
static void RTFDestroyAttrs ( RTF_Info info)
static

Definition at line 122 of file reader.c.

Referenced by RTFDestroy(), and RTFInit().

123 {
124  RTFColor *cp;
125  RTFFont *fp;
126  RTFStyle *sp;
127  RTFStyleElt *eltList, *ep;
128 
129  while (info->fontList)
130  {
131  fp = info->fontList->rtfNextFont;
132  heap_free (info->fontList->rtfFName);
133  heap_free (info->fontList);
134  info->fontList = fp;
135  }
136  while (info->colorList)
137  {
138  cp = info->colorList->rtfNextColor;
139  heap_free (info->colorList);
140  info->colorList = cp;
141  }
142  while (info->styleList)
143  {
144  sp = info->styleList->rtfNextStyle;
145  eltList = info->styleList->rtfSSEList;
146  while (eltList)
147  {
148  ep = eltList->rtfNextSE;
149  heap_free (eltList->rtfSEText);
150  heap_free (eltList);
151  eltList = ep;
152  }
153  heap_free (info->styleList->rtfSName);
154  heap_free (info->styleList);
155  info->styleList = sp;
156  }
157 }
Definition: rtf.h:978
RTFStyle * rtfNextStyle
Definition: rtf.h:998
RTFStyleElt * rtfNextSE
Definition: rtf.h:1009
char * rtfFName
Definition: rtf.h:961
Definition: rtf.h:959
RTFColor * colorList
Definition: rtf.h:1148
char * rtfSName
Definition: rtf.h:990
RTFFont * fontList
Definition: rtf.h:1147
char * rtfSEText
Definition: rtf.h:1008
POINT cp
Definition: magnifier.c:58
static const WCHAR sp[]
Definition: suminfo.c:288
RTFFont * rtfNextFont
Definition: rtf.h:969
RTFStyleElt * rtfSSEList
Definition: rtf.h:996
RTFColor * rtfNextColor
Definition: rtf.h:984
Definition: rtf.h:988
RTFStyle * styleList
Definition: rtf.h:1149
static BOOL heap_free(void *mem)
Definition: appwiz.h:71
static void RTFFlushCPOutputBuffer ( RTF_Info info)
static

Definition at line 2612 of file reader.c.

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

2613 {
2614  int bufferMax = info->dwCPOutputCount * 2 * sizeof(WCHAR);
2615  WCHAR *buffer = heap_alloc(bufferMax);
2616  int length;
2617 
2618  length = MultiByteToWideChar(info->codePage, 0, info->cpOutputBuffer,
2619  info->dwCPOutputCount, buffer, bufferMax/sizeof(WCHAR));
2620  info->dwCPOutputCount = 0;
2621 
2622  RTFPutUnicodeString(info, buffer, length);
2623  heap_free(buffer);
2624 }
int codePage
Definition: rtf.h:1155
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLuint buffer
Definition: glext.h:5915
#define WCHAR
Definition: msvc.h:43
static void * heap_alloc(size_t len)
Definition: appwiz.h:61
DWORD dwCPOutputCount
Definition: rtf.h:1171
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
char * cpOutputBuffer
Definition: rtf.h:1173
#define MultiByteToWideChar
Definition: compat.h:100
static void RTFPutUnicodeString(RTF_Info *info, const WCHAR *string, int length)
Definition: reader.c:2594
static BOOL heap_free(void *mem)
Definition: appwiz.h:71
void RTFFlushOutputBuffer ( RTF_Info info)

Definition at line 2627 of file reader.c.

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

2628 {
2629  if (info->dwCPOutputCount)
2630  RTFFlushCPOutputBuffer(info);
2632 }
static void RTFFlushCPOutputBuffer(RTF_Info *info)
Definition: reader.c:2612
static void RTFFlushUnicodeOutputBuffer(RTF_Info *info)
Definition: reader.c:2582
DWORD dwCPOutputCount
Definition: rtf.h:1171
static void RTFFlushUnicodeOutputBuffer ( RTF_Info info)
static

Definition at line 2582 of file reader.c.

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

2583 {
2584  if (info->dwOutputCount)
2585  {
2587  info->dwOutputCount, info->style);
2588  info->dwOutputCount = 0;
2589  }
2590 }
DWORD dwOutputCount
Definition: rtf.h:1168
ME_TextEditor * editor
Definition: rtf.h:1159
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:1160
WCHAR OutputBuffer[0x1000]
Definition: rtf.h:1169
static RTFFuncPtr RTFGetClassCallback ( const RTF_Info info,
int  class 
)
static

Definition at line 198 of file reader.c.

Referenced by RTFRouteToken().

199 {
200  if (class >= 0 && class < rtfMaxClass)
201  return info->ccb[class];
202  return NULL;
203 }
smooth NULL
Definition: ftsmooth.c:416
#define rtfMaxClass
Definition: rtf.h:83
RTFFuncPtr ccb[rtfMaxClass]
Definition: rtf.h:1162
RTFColor* RTFGetColor ( const RTF_Info info,
int  num 
)

Definition at line 1237 of file reader.c.

Referenced by ME_RTFCharAttrHook().

1238 {
1239  RTFColor *c;
1240 
1241  if (num == -1)
1242  return (info->colorList);
1243  for (c = info->colorList; c != NULL; c = c->rtfNextColor)
1244  {
1245  if (c->rtfCNum == num)
1246  break;
1247  }
1248  return (c); /* NULL if not found */
1249 }
Definition: rtf.h:978
RTFColor * colorList
Definition: rtf.h:1148
smooth NULL
Definition: ftsmooth.c:416
GLuint GLuint num
Definition: glext.h:9618
int rtfCNum
Definition: rtf.h:980
#define c
Definition: ke_i.h:80
RTFColor * rtfNextColor
Definition: rtf.h:984
static RTFFuncPtr RTFGetDestinationCallback ( const RTF_Info info,
int  dest 
)
static

Definition at line 288 of file reader.c.

Referenced by Destination(), and RTFRouteToken().

289 {
290  if (dest >= 0 && dest < rtfMaxDestination)
291  return info->dcb[dest];
292  return NULL;
293 }
smooth NULL
Definition: ftsmooth.c:416
GLfloat CONST GLvector4f CONST GLfloat GLvector4f * dest
Definition: m_xform.h:122
RTFFuncPtr dcb[rtfMaxDestination]
Definition: rtf.h:1164
#define rtfMaxDestination
Definition: rtf.h:189
RTFFont* RTFGetFont ( const RTF_Info info,
int  num 
)

Definition at line 1222 of file reader.c.

Referenced by CharAttr(), and ME_RTFCharAttrHook().

1223 {
1224  RTFFont *f;
1225 
1226  if (num == -1)
1227  return (info->fontList);
1228  for (f = info->fontList; f != NULL; f = f->rtfNextFont)
1229  {
1230  if (f->rtfFNum == num)
1231  break;
1232  }
1233  return (f); /* NULL if not found */
1234 }
Definition: rtf.h:959
smooth NULL
Definition: ftsmooth.c:416
RTFFont * fontList
Definition: rtf.h:1147
GLuint GLuint num
Definition: glext.h:9618
#define f
Definition: ke_i.h:83
int rtfFNum
Definition: rtf.h:963
RTFFont * rtfNextFont
Definition: rtf.h:969
static RTFFuncPtr RTFGetReadHook ( const RTF_Info info)
static

Definition at line 394 of file reader.c.

Referenced by RTFGetToken().

395 {
396  return (info->readHook);
397 }
RTFFuncPtr readHook
Definition: rtf.h:1166
int RTFGetToken ( RTF_Info info)

Definition at line 406 of file reader.c.

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

407 {
408  RTFFuncPtr p;
409 
410  /* don't try to return anything once EOF is reached */
411  if (info->rtfClass == rtfEOF) {
412  return rtfEOF;
413  }
414 
415  for (;;)
416  {
417  _RTFGetToken (info);
418  p = RTFGetReadHook (info);
419  if (p != NULL)
420  (*p) (info); /* give read hook a look at token */
421 
422  /* Silently discard newlines, carriage returns, nulls. */
423  if (!(info->rtfClass == rtfText && info->rtfFormat != SF_TEXT
424  && (info->rtfMajor == '\r' || info->rtfMajor == '\n' || info->rtfMajor == '\0')))
425  break;
426  }
427  return (info->rtfClass);
428 }
static RTFFuncPtr RTFGetReadHook(const RTF_Info *info)
Definition: reader.c:394
static void _RTFGetToken(RTF_Info *)
Definition: reader.c:454
smooth NULL
Definition: ftsmooth.c:416
#define SF_TEXT
Definition: richedit.h:720
int rtfClass
Definition: rtf.h:1119
void(* RTFFuncPtr)(RTF_Info *)
Definition: rtf.h:1095
#define rtfText
Definition: rtf.h:80
int rtfFormat
Definition: rtf.h:1123
const XML_Char XML_Encoding * info
Definition: expat.h:530
int rtfMajor
Definition: rtf.h:1120
GLfloat GLfloat p
Definition: glext.h:8902
#define rtfEOF
Definition: rtf.h:82
void RTFInit ( RTF_Info info)

Definition at line 212 of file reader.c.

Referenced by ME_StreamIn().

213 {
214  int i;
215 
216  if (info->rtfTextBuf == NULL) /* initialize the text buffers */
217  {
218  info->rtfTextBuf = heap_alloc (rtfBufSiz);
220  if (info->rtfTextBuf == NULL || info->pushedTextBuf == NULL) {
221  ERR ("Cannot allocate text buffers.\n");
222  return;
223  }
224  info->rtfTextBuf[0] = info->pushedTextBuf[0] = '\0';
225  }
226 
227  for (i = 0; i < rtfMaxClass; i++)
228  RTFSetClassCallback (info, i, NULL);
229  for (i = 0; i < rtfMaxDestination; i++)
230  RTFSetDestinationCallback (info, i, NULL);
231 
232  /* install built-in destination readers */
239 
240 
241  RTFSetReadHook (info, NULL);
242 
243  /* dump old lists if necessary */
244 
245  RTFDestroyAttrs(info);
246 
247  info->ansiCodePage = 1252; /* Latin-1; actually unused */
248  info->unicodeLength = 1; /* \uc1 is the default */
249  info->codePage = info->ansiCodePage;
250  info->defFont = 0;
251 
252  info->rtfClass = -1;
253  info->pushedClass = -1;
254  info->pushedChar = EOF;
255 
256  info->rtfLineNum = 0;
257  info->rtfLinePos = 0;
258  info->prevChar = EOF;
259  info->bumpLine = FALSE;
260 
261  info->dwCPOutputCount = 0;
262  if (!info->cpOutputBuffer)
263  {
264  info->dwMaxCPOutputCount = 0x1000;
266  }
267 
268  info->tableDef = NULL;
269  info->nestingLevel = 0;
270  info->canInheritInTbl = FALSE;
271  info->borderType = 0;
272 
273  memset(&info->fmt, 0, sizeof(info->fmt));
274  info->fmt.cbSize = sizeof(info->fmt);
275 }
PARAFORMAT2 fmt
Definition: rtf.h:1184
static void RTFDestroyAttrs(RTF_Info *info)
Definition: reader.c:122
int codePage
Definition: rtf.h:1155
#define rtfFontTbl
Definition: rtf.h:110
static void RTFSetClassCallback(RTF_Info *info, int class, RTFFuncPtr callback)
Definition: reader.c:191
int pushedClass
Definition: rtf.h:1137
RTFTable * tableDef
Definition: rtf.h:1179
static void ReadObjGroup(RTF_Info *)
Definition: reader.c:1208
int rtfLineNum
Definition: rtf.h:1127
static void ReadColorTbl(RTF_Info *)
Definition: reader.c:965
#define rtfColorTbl
Definition: rtf.h:116
static void * heap_alloc(size_t len)
Definition: appwiz.h:61
char * rtfTextBuf
Definition: rtf.h:1124
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define FALSE
Definition: types.h:117
DWORD dwCPOutputCount
Definition: rtf.h:1171
#define rtfBufSiz
Definition: rtf.h:30
smooth NULL
Definition: ftsmooth.c:416
static void ReadPictGroup(RTF_Info *)
Definition: reader.c:1201
BOOL bumpLine
Definition: rtf.h:1144
int rtfClass
Definition: rtf.h:1119
void RTFSetDestinationCallback(RTF_Info *info, int dest, RTFFuncPtr callback)
Definition: reader.c:281
int unicodeLength
Definition: rtf.h:1154
int pushedChar
Definition: rtf.h:1135
char * pushedTextBuf
Definition: rtf.h:1141
char * cpOutputBuffer
Definition: rtf.h:1173
int defFont
Definition: rtf.h:1151
#define rtfInfo
Definition: rtf.h:120
#define rtfMaxClass
Definition: rtf.h:83
int ansiCodePage
Definition: rtf.h:1150
#define rtfMaxDestination
Definition: rtf.h:189
static void ReadStyleSheet(RTF_Info *)
Definition: reader.c:1025
int prevChar
Definition: rtf.h:1143
#define rtfPict
Definition: rtf.h:154
#define ERR(fmt,...)
Definition: debug.h:109
#define rtfStyleSheet
Definition: rtf.h:117
static void ReadInfoGroup(RTF_Info *)
Definition: reader.c:1194
#define rtfObject
Definition: rtf.h:155
int nestingLevel
Definition: rtf.h:1180
static void ReadFontTbl(RTF_Info *)
Definition: reader.c:786
int rtfLinePos
Definition: rtf.h:1128
void RTFSetReadHook(RTF_Info *info, RTFFuncPtr f)
Definition: reader.c:388
DWORD dwMaxCPOutputCount
Definition: rtf.h:1172
#define EOF
Definition: stdio.h:24
UINT cbSize
Definition: richedit.h:666
BOOL canInheritInTbl
Definition: rtf.h:1181
#define memset(x, y, z)
Definition: compat.h:39
int borderType
Definition: rtf.h:1182
static void RTFPutCodePageChar ( RTF_Info info,
int  c 
)
static

Definition at line 2645 of file reader.c.

Referenced by TextClass().

2646 {
2647  /* Use dynamic buffer here because it's the best way to handle
2648  * MBCS codepages without having to worry about partial chars */
2649  if (info->dwCPOutputCount >= info->dwMaxCPOutputCount)
2650  {
2651  info->dwMaxCPOutputCount *= 2;
2653  }
2654  info->cpOutputBuffer[info->dwCPOutputCount++] = c;
2655 }
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:66
DWORD dwCPOutputCount
Definition: rtf.h:1171
char * cpOutputBuffer
Definition: rtf.h:1173
DWORD dwMaxCPOutputCount
Definition: rtf.h:1172
#define c
Definition: ke_i.h:80
static void RTFPutUnicodeChar ( RTF_Info info,
int  c 
)
static

Definition at line 2635 of file reader.c.

Referenced by SpecialChar().

2636 {
2637  if (info->dwCPOutputCount)
2638  RTFFlushCPOutputBuffer(info);
2639  if (info->dwOutputCount * sizeof(WCHAR) >= ( sizeof info->OutputBuffer - 1 ) )
2641  info->OutputBuffer[info->dwOutputCount++] = c;
2642 }
DWORD dwOutputCount
Definition: rtf.h:1168
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void RTFFlushCPOutputBuffer(RTF_Info *info)
Definition: reader.c:2612
static void RTFFlushUnicodeOutputBuffer(RTF_Info *info)
Definition: reader.c:2582
DWORD dwCPOutputCount
Definition: rtf.h:1171
#define c
Definition: ke_i.h:80
WCHAR OutputBuffer[0x1000]
Definition: rtf.h:1169
static void RTFPutUnicodeString ( RTF_Info info,
const WCHAR string,
int  length 
)
static

Definition at line 2594 of file reader.c.

Referenced by RTFFlushCPOutputBuffer().

2595 {
2596  if (info->dwCPOutputCount)
2597  RTFFlushCPOutputBuffer(info);
2598  while (length)
2599  {
2600  int fit = min(length, sizeof(info->OutputBuffer) / sizeof(WCHAR) - info->dwOutputCount);
2601 
2602  memmove(info->OutputBuffer + info->dwOutputCount, string, fit * sizeof(WCHAR));
2603  info->dwOutputCount += fit;
2604  length -= fit;
2605  string += fit;
2606  if (sizeof(info->OutputBuffer) / sizeof(WCHAR) == info->dwOutputCount)
2608  }
2609 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
DWORD dwOutputCount
Definition: rtf.h:1168
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void RTFFlushCPOutputBuffer(RTF_Info *info)
Definition: reader.c:2612
static void RTFFlushUnicodeOutputBuffer(RTF_Info *info)
Definition: reader.c:2582
DWORD dwCPOutputCount
Definition: rtf.h:1171
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define min(a, b)
Definition: monoChain.cc:55
WCHAR OutputBuffer[0x1000]
Definition: rtf.h:1169
void RTFRead ( RTF_Info info)

Definition at line 308 of file reader.c.

Referenced by ME_StreamIn().

309 {
310  while (RTFGetToken (info) != rtfEOF)
311  RTFRouteToken (info);
312 }
int RTFGetToken(RTF_Info *info)
Definition: reader.c:406
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:321
#define rtfEOF
Definition: rtf.h:82
void RTFReadGroup ( RTF_Info info)

Definition at line 379 of file reader.c.

Referenced by ME_StreamIn().

380 {
381 }
void RTFRouteToken ( RTF_Info info)

Definition at line 321 of file reader.c.

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

322 {
323  RTFFuncPtr p;
324 
325  if (info->rtfClass < 0 || info->rtfClass >= rtfMaxClass) /* watchdog */
326  {
327  ERR( "Unknown class %d: %s (reader malfunction)\n",
328  info->rtfClass, info->rtfTextBuf);
329  }
330  if (RTFCheckCM (info, rtfControl, rtfDestination))
331  {
332  /* invoke destination-specific callback if there is one */
333  p = RTFGetDestinationCallback (info, info->rtfMinor);
334  if (p != NULL)
335  {
336  (*p) (info);
337  return;
338  }
339  }
340  /* invoke class callback if there is one */
341  p = RTFGetClassCallback (info, info->rtfClass);
342  if (p != NULL)
343  (*p) (info);
344 }
char * rtfTextBuf
Definition: rtf.h:1124
static RTFFuncPtr RTFGetClassCallback(const RTF_Info *info, int class)
Definition: reader.c:198
int RTFCheckCM(const RTF_Info *info, int class, int major)
Definition: reader.c:2277
smooth NULL
Definition: ftsmooth.c:416
int rtfMinor
Definition: rtf.h:1121
int rtfClass
Definition: rtf.h:1119
void(* RTFFuncPtr)(RTF_Info *)
Definition: rtf.h:1095
#define rtfControl
Definition: rtf.h:81
#define rtfMaxClass
Definition: rtf.h:83
static RTFFuncPtr RTFGetDestinationCallback(const RTF_Info *info, int dest)
Definition: reader.c:288
#define ERR(fmt,...)
Definition: debug.h:109
const XML_Char XML_Encoding * info
Definition: expat.h:530
#define rtfDestination
Definition: rtf.h:109
GLfloat GLfloat p
Definition: glext.h:8902
static void RTFSetClassCallback ( RTF_Info info,
int  class,
RTFFuncPtr  callback 
)
static

Definition at line 191 of file reader.c.

Referenced by BeginFile(), and RTFInit().

192 {
193  if (class >= 0 && class < rtfMaxClass)
194  info->ccb[class] = callback;
195 }
MmuTrapHandler callback[0x30]
Definition: mmuobject.c:44
#define rtfMaxClass
Definition: rtf.h:83
RTFFuncPtr ccb[rtfMaxClass]
Definition: rtf.h:1162
void RTFSetDestinationCallback ( RTF_Info info,
int  dest,
RTFFuncPtr  callback 
)

Definition at line 281 of file reader.c.

Referenced by ME_StreamIn(), and RTFInit().

282 {
283  if (dest >= 0 && dest < rtfMaxDestination)
284  info->dcb[dest] = callback;
285 }
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:1164
#define rtfMaxDestination
Definition: rtf.h:189
void RTFSetEditStream ( RTF_Info info,
ME_InStream stream 
)

Definition at line 116 of file reader.c.

Referenced by ME_StreamIn().

117 {
118  info->stream = stream;
119 }
ME_InStream * stream
Definition: rtf.h:1157
GLuint GLuint stream
Definition: glext.h:7522
void RTFSetReadHook ( RTF_Info info,
RTFFuncPtr  f 
)

Definition at line 388 of file reader.c.

Referenced by ME_StreamIn(), and RTFInit().

389 {
390  info->readHook = f;
391 }
RTFFuncPtr readHook
Definition: rtf.h:1166
#define f
Definition: ke_i.h:83
void RTFSkipGroup ( RTF_Info info)

Definition at line 354 of file reader.c.

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

355 {
356  int level = 1;
357 
358  while (RTFGetToken (info) != rtfEOF)
359  {
360  if (info->rtfClass == rtfGroup)
361  {
362  if (info->rtfMajor == rtfBeginGroup)
363  ++level;
364  else if (info->rtfMajor == rtfEndGroup)
365  {
366  if (--level < 1)
367  break; /* end of initial group */
368  }
369  }
370  }
371 }
GLint level
Definition: gl.h:1546
#define rtfBeginGroup
Definition: rtf.h:89
#define rtfEndGroup
Definition: rtf.h:90
#define rtfGroup
Definition: rtf.h:79
int rtfClass
Definition: rtf.h:1119
int RTFGetToken(RTF_Info *info)
Definition: reader.c:406
int rtfMajor
Definition: rtf.h:1120
#define rtfEOF
Definition: rtf.h:82
static char* RTFStrSave ( const char s)
inlinestatic

Definition at line 81 of file reader.c.

Referenced by ReadFontTbl(), and ReadStyleSheet().

82 {
83  char *p;
84 
85  p = heap_alloc (lstrlenA(s) + 1);
86  if (p == NULL)
87  return NULL;
88  return lstrcpyA (p, s);
89 }
static void * heap_alloc(size_t len)
Definition: appwiz.h:61
smooth NULL
Definition: ftsmooth.c:416
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
GLdouble s
Definition: gl.h:2039
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
GLfloat GLfloat p
Definition: glext.h:8902
static void RTFUngetToken ( RTF_Info info)
static

Definition at line 431 of file reader.c.

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

432 {
433  if (info->pushedClass >= 0) /* there's already an ungotten token */
434  ERR ("cannot unget two tokens\n");
435  if (info->rtfClass < 0)
436  ERR ("no token to unget\n");
437  info->pushedClass = info->rtfClass;
438  info->pushedMajor = info->rtfMajor;
439  info->pushedMinor = info->rtfMinor;
440  info->pushedParam = info->rtfParam;
441  lstrcpyA (info->pushedTextBuf, info->rtfTextBuf);
442  /* The read hook decrements stackTop on rtfEndGroup, so
443  * increment the value to compensate for it being decremented
444  * twice due to the RTFUngetToken. */
445  if(RTFCheckCM (info, rtfGroup, rtfEndGroup))
446  {
447  info->stack[info->stackTop].style = info->style;
448  ME_AddRefStyle(info->style);
449  info->stackTop++;
450  }
451 }
int pushedParam
Definition: rtf.h:1140
#define rtfEndGroup
Definition: rtf.h:90
int pushedMinor
Definition: rtf.h:1139
int pushedClass
Definition: rtf.h:1137
int rtfParam
Definition: rtf.h:1122
#define rtfGroup
Definition: rtf.h:79
ME_Style * style
Definition: rtf.h:1160
char * rtfTextBuf
Definition: rtf.h:1124
int pushedMajor
Definition: rtf.h:1138
int stackTop
Definition: rtf.h:1176
int RTFCheckCM(const RTF_Info *info, int class, int major)
Definition: reader.c:2277
int rtfMinor
Definition: rtf.h:1121
ME_Style * style
Definition: rtf.h:1100
int rtfClass
Definition: rtf.h:1119
char * pushedTextBuf
Definition: rtf.h:1141
void ME_AddRefStyle(ME_Style *item) DECLSPEC_HIDDEN
Definition: style.c:432
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
#define ERR(fmt,...)
Definition: debug.h:109
int rtfMajor
Definition: rtf.h:1120
RTFState stack[maxStack]
Definition: rtf.h:1175
static void SpecialChar ( RTF_Info info)
static

Definition at line 2482 of file reader.c.

Referenced by ControlClass().

2483 {
2484  switch (info->rtfMinor)
2485  {
2486  case rtfOptDest:
2487  /* the next token determines destination, if it's unknown, skip the group */
2488  /* this way we filter out the garbage coming from unknown destinations */
2489  RTFGetToken(info);
2490  if (info->rtfClass != rtfDestination)
2491  RTFSkipGroup(info);
2492  else
2493  RTFRouteToken(info); /* "\*" is ignored with known destinations */
2494  break;
2495  case rtfUnicode:
2496  {
2497  int i;
2498 
2499  RTFPutUnicodeChar(info, info->rtfParam);
2500 
2501  /* After \u we must skip number of character tokens set by \ucN */
2502  for (i = 0; i < info->unicodeLength; i++)
2503  {
2504  RTFGetToken(info);
2505  if (info->rtfClass != rtfText)
2506  {
2507  ERR("The token behind \\u is not text, but (%d,%d,%d)\n",
2508  info->rtfClass, info->rtfMajor, info->rtfMinor);
2509  RTFUngetToken(info);
2510  break;
2511  }
2512  }
2513  break;
2514  }
2515  case rtfLine:
2516  RTFFlushOutputBuffer(info);
2518  break;
2519  case rtfPage:
2520  case rtfSect:
2521  case rtfPar:
2522  RTFFlushOutputBuffer(info);
2523  ME_SetSelectionParaFormat(info->editor, &info->fmt);
2524  memset(&info->fmt, 0, sizeof(info->fmt));
2525  info->fmt.cbSize = sizeof(info->fmt);
2526  RTFPutUnicodeChar (info, '\r');
2527  if (info->editor->bEmulateVersion10) RTFPutUnicodeChar (info, '\n');
2528  break;
2529  case rtfNoBrkSpace:
2530  RTFPutUnicodeChar (info, 0x00A0);
2531  break;
2532  case rtfTab:
2533  RTFPutUnicodeChar (info, '\t');
2534  break;
2535  case rtfNoBrkHyphen:
2536  RTFPutUnicodeChar (info, 0x2011);
2537  break;
2538  case rtfBullet:
2539  RTFPutUnicodeChar (info, 0x2022);
2540  break;
2541  case rtfEmDash:
2542  RTFPutUnicodeChar (info, 0x2014);
2543  break;
2544  case rtfEnDash:
2545  RTFPutUnicodeChar (info, 0x2013);
2546  break;
2547  case rtfEmSpace:
2548  RTFPutUnicodeChar (info, ' ');
2549  break;
2550  case rtfEnSpace:
2551  RTFPutUnicodeChar (info, ' ');
2552  break;
2553  case rtfLQuote:
2554  RTFPutUnicodeChar (info, 0x2018);
2555  break;
2556  case rtfRQuote:
2557  RTFPutUnicodeChar (info, 0x2019);
2558  break;
2559  case rtfLDblQuote:
2560  RTFPutUnicodeChar (info, 0x201C);
2561  break;
2562  case rtfRDblQuote:
2563  RTFPutUnicodeChar (info, 0x201D);
2564  break;
2565  case rtfLTRMark:
2566  RTFPutUnicodeChar (info, 0x200E);
2567  break;
2568  case rtfRTLMark:
2569  RTFPutUnicodeChar (info, 0x200F);
2570  break;
2571  case rtfNoWidthJoiner:
2572  RTFPutUnicodeChar (info, 0x200D);
2573  break;
2574  case rtfNoWidthNonJoiner:
2575  RTFPutUnicodeChar (info, 0x200C);
2576  break;
2577  }
2578 }
#define rtfSect
Definition: rtf.h:238
PARAFORMAT2 fmt
Definition: rtf.h:1184
#define rtfRTLMark
Definition: rtf.h:262
#define rtfNoWidthJoiner
Definition: rtf.h:263
#define rtfRDblQuote
Definition: rtf.h:255
#define rtfEnDash
Definition: rtf.h:248
ME_TextEditor * editor
Definition: rtf.h:1159
#define rtfEmSpace
Definition: rtf.h:249
BOOL ME_SetSelectionParaFormat(ME_TextEditor *editor, const PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN
Definition: para.c:779
int rtfParam
Definition: rtf.h:1122
#define rtfEmDash
Definition: rtf.h:247
void ME_InsertEndRowFromCursor(ME_TextEditor *editor, int nCursor)
Definition: caret.c:493
void RTFSkipGroup(RTF_Info *info)
Definition: reader.c:354
#define rtfNoBrkSpace
Definition: rtf.h:257
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define rtfUnicode
Definition: rtf.h:267
#define rtfLDblQuote
Definition: rtf.h:254
#define rtfPage
Definition: rtf.h:239
void RTFFlushOutputBuffer(RTF_Info *info)
Definition: reader.c:2627
#define rtfPar
Definition: rtf.h:237
#define rtfNoBrkHyphen
Definition: rtf.h:259
int rtfMinor
Definition: rtf.h:1121
#define rtfEnSpace
Definition: rtf.h:250
#define rtfOptDest
Definition: rtf.h:260
#define rtfRQuote
Definition: rtf.h:253
int rtfClass
Definition: rtf.h:1119
int unicodeLength
Definition: rtf.h:1154
int RTFGetToken(RTF_Info *info)
Definition: reader.c:406
#define rtfTab
Definition: rtf.h:246
#define rtfText
Definition: rtf.h:80
#define rtfLQuote
Definition: rtf.h:252
#define ERR(fmt,...)
Definition: debug.h:109
static void RTFUngetToken(RTF_Info *info)
Definition: reader.c:431
#define rtfDestination
Definition: rtf.h:109
BOOL bEmulateVersion10
Definition: editstr.h:382
#define rtfNoWidthNonJoiner
Definition: rtf.h:264
int rtfMajor
Definition: rtf.h:1120
#define rtfLine
Definition: rtf.h:241
static void RTFPutUnicodeChar(RTF_Info *info, int c)
Definition: reader.c:2635
#define rtfLTRMark
Definition: rtf.h:261
UINT cbSize
Definition: richedit.h:666
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:321
#define memset(x, y, z)
Definition: compat.h:39
#define rtfBullet
Definition: rtf.h:251
static void TextClass ( RTF_Info info)
static

Definition at line 2351 of file reader.c.

Referenced by BeginFile().

2352 {
2353  RTFPutCodePageChar(info, info->rtfMajor);
2354 }
static void RTFPutCodePageChar(RTF_Info *info, int c)
Definition: reader.c:2645
int rtfMajor
Definition: rtf.h:1120
WINE_DEFAULT_DEBUG_CHANNEL ( richedit  )
void WriterInit ( RTF_Info info)

Definition at line 2330 of file reader.c.

Referenced by ME_StreamIn().

2331 {
2332 }

Variable Documentation

RTFHashTableEntry rtfHashTable[RTF_KEY_COUNT *2]
static

Definition at line 2185 of file reader.c.

RTFKey rtfKey[]
static

Definition at line 1274 of file reader.c.