ReactOS 0.4.16-dev-250-g3ecd236
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
 

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 [ARRAY_SIZE(rtfKey) *2]
 

Typedef Documentation

◆ RTFHashTableEntry

◆ RTFKey

typedef struct RTFKey RTFKey

Definition at line 1259 of file reader.c.

Function Documentation

◆ _RTFGetChar()

int _RTFGetChar ( RTF_Info info)
static

Definition at line 95 of file reader.c.

96{
97 int ch;
98 ME_InStream *stream = info->stream;
99
100 if (stream->dwSize <= stream->dwUsed)
101 {
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 ' ';
113 return ch;
114}
void ME_StreamInFill(ME_InStream *stream)
Definition: editor.c:1576
unsigned char
Definition: typeof.h:29
#define EOF
Definition: stdio.h:24
if(dx< 0)
Definition: linetemp.h:194
Definition: parse.h:23

Referenced by GetChar().

◆ _RTFGetToken()

static void _RTFGetToken ( RTF_Info info)
static

Definition at line 454 of file reader.c.

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
489}
static void _RTFGetToken2(RTF_Info *)
Definition: reader.c:554
static int GetChar(RTF_Info *)
Definition: reader.c:725
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define SF_TEXT
Definition: richedit.h:720
#define rtfEOF
Definition: rtf.h:82
#define rtfNoParam
Definition: rtf.h:62
#define rtfText
Definition: rtf.h:80

Referenced by RTFGetToken().

◆ _RTFGetToken2()

static void _RTFGetToken2 ( RTF_Info info)
static

Definition at line 554 of file reader.c.

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}
#define isalpha(c)
Definition: acclib.h:74
#define isdigit(c)
Definition: acclib.h:68
#define isxdigit(c)
Definition: acclib.h:70
static void Lookup(RTF_Info *, char *)
Definition: reader.c:2228
int RTFCharToHex(char c)
Definition: reader.c:2297
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
#define sign(x)
Definition: mapdesc.cc:613
#define rtfBeginGroup
Definition: rtf.h:89
#define rtfEndGroup
Definition: rtf.h:90
#define rtfSpecialChar
Definition: rtf.h:206
#define rtfTab
Definition: rtf.h:246
#define rtfControl
Definition: rtf.h:81
#define rtfGroup
Definition: rtf.h:79
#define rtfUnknown
Definition: rtf.h:78

Referenced by _RTFGetToken().

◆ BeginFile()

int BeginFile ( RTF_Info info)

Definition at line 2335 of file reader.c.

2336{
2337 /* install class callbacks */
2338
2341
2342 return (1);
2343}
static const WCHAR ControlClass[]
Definition: cfgmgr.c:44
static void RTFSetClassCallback(RTF_Info *info, int class, RTFFuncPtr callback)
Definition: reader.c:191
static void TextClass(RTF_Info *info)
Definition: reader.c:2350

Referenced by ME_StreamIn().

◆ CharAttr()

static void CharAttr ( RTF_Info info)
static

Definition at line 2392 of file reader.c.

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

Referenced by ControlClass().

◆ CharSet()

static void CharSet ( RTF_Info info)
static

Definition at line 2420 of file reader.c.

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

Referenced by AddDlg_OnInitDialog(), ControlClass(), EditDlg_OnInitDialog(), GetFontSig(), IntGetCharSet(), is_charset_font_installed(), is_fixed_charset_font_installed(), main(), NameFromCharSet(), and T1_OnImeControl().

◆ ControlClass()

static void ControlClass ( RTF_Info info)
static

Definition at line 2357 of file reader.c.

2358{
2359 switch (info->rtfMajor)
2360 {
2361 case rtfCharAttr:
2362 CharAttr(info);
2364 break;
2365 case rtfParAttr:
2367 break;
2368 case rtfTblAttr:
2370 break;
2371 case rtfCharSet:
2372 CharSet(info);
2373 break;
2374 case rtfDefFont:
2375 DefFont(info);
2376 break;
2377 case rtfDestination:
2378 Destination (info);
2379 break;
2380 case rtfDocAttr:
2381 DocAttr(info);
2382 break;
2383 case rtfSpecialChar:
2384 SpecialChar (info);
2386 break;
2387 }
2388}
void ME_RTFTblAttrHook(RTF_Info *info)
Definition: editor.c:874
void ME_RTFCharAttrHook(RTF_Info *info)
Definition: editor.c:425
void ME_RTFSpecialCharHook(RTF_Info *info)
Definition: editor.c:948
void ME_RTFParAttrHook(RTF_Info *info)
Definition: editor.c:556
static void CharAttr(RTF_Info *info)
Definition: reader.c:2392
static void SpecialChar(RTF_Info *info)
Definition: reader.c:2481
static void CharSet(RTF_Info *info)
Definition: reader.c:2420
static void DocAttr(RTF_Info *info)
Definition: reader.c:2465
static void DefFont(RTF_Info *info)
Definition: reader.c:2457
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3016
#define rtfTblAttr
Definition: rtf.h:414
#define rtfCharAttr
Definition: rtf.h:562
#define rtfDefFont
Definition: rtf.h:98
#define rtfParAttr
Definition: rtf.h:455
#define rtfCharSet
Definition: rtf.h:100
#define rtfDocAttr
Definition: rtf.h:276
#define rtfDestination
Definition: rtf.h:109

◆ DefFont()

static void DefFont ( RTF_Info info)
static

Definition at line 2457 of file reader.c.

2458{
2459 TRACE("%d\n", info->rtfParam);
2460 info->defFont = info->rtfParam;
2461}

Referenced by ControlClass().

◆ Destination()

static void Destination ( RTF_Info info)
static

Definition at line 2449 of file reader.c.

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

◆ DocAttr()

static void DocAttr ( RTF_Info info)
static

Definition at line 2465 of file reader.c.

2466{
2467 TRACE("minor %d, param %d\n", info->rtfMinor, info->rtfParam);
2468
2469 switch (info->rtfMinor)
2470 {
2471 case rtfAnsiCodePage:
2472 info->codePage = info->ansiCodePage = info->rtfParam;
2473 break;
2474 case rtfUTF8RTF:
2475 info->codePage = info->ansiCodePage = CP_UTF8;
2476 break;
2477 }
2478}
#define rtfAnsiCodePage
Definition: rtf.h:355
#define rtfUTF8RTF
Definition: rtf.h:356

Referenced by ControlClass().

◆ GetChar()

static int GetChar ( RTF_Info info)
static

Definition at line 725 of file reader.c.

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
#define FALSE
Definition: types.h:117
static int _RTFGetChar(RTF_Info *)
Definition: reader.c:95
unsigned int BOOL
Definition: ntddk_ex.h:94

Referenced by _RTFGetToken(), and _RTFGetToken2().

◆ Hash()

◆ Lookup()

static void Lookup ( RTF_Info info,
char s 
)
static

Definition at line 2228 of file reader.c.

2229{
2230 RTFKey *rp;
2231 int hash;
2233 int i;
2234
2235 ++s; /* skip over the leading \ character */
2236 hash = Hash (s);
2238 for (i = 0; i < entry->count; i++)
2239 {
2240 rp = entry->value[i];
2241 if (hash == rp->rtfKHash && strcmp (s, rp->rtfKStr) == 0)
2242 {
2243 info->rtfClass = rtfControl;
2244 info->rtfMajor = rp->rtfKMajor;
2245 info->rtfMinor = rp->rtfKMinor;
2246 return;
2247 }
2248 }
2249 info->rtfClass = rtfUnknown;
2250}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ARRAY_SIZE(A)
Definition: main.h:20
static RTFHashTableEntry rtfHashTable[ARRAY_SIZE(rtfKey) *2]
Definition: reader.c:2184
static int Hash(const char *)
Definition: reader.c:2257
static RTFKey rtfKey[]
Definition: reader.c:1274
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
uint32_t entry
Definition: isohybrid.c:63
int rtfKMajor
Definition: reader.c:1263
const char * rtfKStr
Definition: reader.c:1265
int rtfKMinor
Definition: reader.c:1264
int rtfKHash
Definition: reader.c:1266
Definition: _hash_fun.h:40

Referenced by _RTFGetToken2(), ApphelpCacheLookupEntry(), ApphelpCacheUpdateEntry(), BasepShimCacheRemoveEntry(), BasepShimCacheSearch(), GetProtoPatternMatch(), and RtlLookupElementGenericTableAvl().

◆ LookupCleanup()

void LookupCleanup ( void  )

Definition at line 2210 of file reader.c.

2211{
2212 unsigned int i;
2213
2214 for (i = 0; i < ARRAY_SIZE(rtfKey) * 2; i++)
2215 {
2218 rtfHashTable[i].count = 0;
2219 }
2220}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define NULL
Definition: types.h:112
RTFKey ** value
Definition: reader.c:2181
Definition: pdh_main.c:94

Referenced by DllMain().

◆ LookupInit()

void LookupInit ( void  )

Definition at line 2191 of file reader.c.

2192{
2193 RTFKey *rp;
2194
2195 memset(rtfHashTable, 0, sizeof rtfHashTable);
2196 for (rp = rtfKey; rp->rtfKStr != NULL; rp++)
2197 {
2198 int index;
2199
2200 rp->rtfKHash = Hash (rp->rtfKStr);
2201 index = rp->rtfKHash % (ARRAY_SIZE(rtfKey) * 2);
2202 if (!rtfHashTable[index].count)
2204 else
2207 }
2208}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:71
#define index(s, c)
Definition: various.h:29
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint index
Definition: glext.h:6031
#define memset(x, y, z)
Definition: compat.h:39

Referenced by DllMain().

◆ ReadColorTbl()

static void ReadColorTbl ( RTF_Info info)
static

Definition at line 965 of file reader.c.

966{
967 RTFColor *cp;
968 int cnum = 0;
969 int group_level = 1;
970
971 for (;;)
972 {
974 if (info->rtfClass == rtfEOF)
975 break;
977 {
978 group_level--;
979 if (!group_level)
980 break;
981 continue;
982 }
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;
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}
int RTFCheckCM(const RTF_Info *info, int class, int major)
Definition: reader.c:2276
int RTFGetToken(RTF_Info *info)
Definition: reader.c:406
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:321
POINT cp
Definition: magnifier.c:59
#define rtfColorName
Definition: rtf.h:201
#define rtfGreen
Definition: rtf.h:203
#define New(t)
Definition: rtf.h:1086
#define rtfBlue
Definition: rtf.h:204
#define rtfRed
Definition: rtf.h:202
Definition: rtf.h:979

Referenced by RTFInit().

◆ ReadFontTbl()

static void ReadFontTbl ( RTF_Info info)
static

Definition at line 786 of file reader.c.

787{
788 RTFFont *fp = NULL;
789 char buf[rtfBufSiz], *bp;
790 int old = -1;
791
792 for (;;)
793 {
795 if (info->rtfClass == rtfEOF)
796 break;
798 break;
799 if (old < 0) /* first entry - determine tbl type */
800 {
802 old = 1; /* no brace */
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 {
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;
829 fp->rtfFCharSet = DEFAULT_CHARSET; /* 1 */
831 fp->rtfFType = 0;
832 fp->rtfFCodePage = CP_ACP;
833
834 while (info->rtfClass != rtfEOF
835 && !RTFCheckCM (info, rtfText, ';')
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;
896 }
897
898 /* FIX: in some cases the <fontinfo> isn't finished with a semi-column */
900 {
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 }
917 if (info->rtfClass == rtfEOF)
918 break;
919 }
920 if (info->rtfClass == rtfEOF)
921 break;
922 if (old == 0) /* need to see "}" here */
923 {
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");
953}
#define WARN(fmt,...)
Definition: precomp.h:61
#define CP_ACP
Definition: compat.h:109
int RTFCharSetToCodePage(RTF_Info *info, int charset)
Definition: reader.c:493
static void RTFUngetToken(RTF_Info *info)
Definition: reader.c:431
static char * RTFStrSave(const char *s)
Definition: reader.c:81
int RTFCheckCMM(const RTF_Info *info, int class, int major, int minor)
Definition: reader.c:2282
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define rtfFontFamily
Definition: rtf.h:191
#define rtfFontAttr
Definition: rtf.h:734
#define rtfFTypeTrueType
Definition: rtf.h:739
#define rtfBufSiz
Definition: rtf.h:30
#define rtfFontCodePage
Definition: rtf.h:737
#define rtfFTypeNil
Definition: rtf.h:738
#define rtfFontCharSet
Definition: rtf.h:735
#define rtfFontPitch
Definition: rtf.h:736
int rtfFNum
Definition: rtf.h:963
int rtfFType
Definition: rtf.h:967
int rtfFPitch
Definition: rtf.h:966
int rtfFFamily
Definition: rtf.h:964
RTFFont * rtfNextFont
Definition: rtf.h:969
char * rtfFName
Definition: rtf.h:961
int rtfFCodePage
Definition: rtf.h:968
int rtfFCharSet
Definition: rtf.h:965
char * rtfFAltName
Definition: rtf.h:962
#define DEFAULT_PITCH
Definition: wingdi.h:443
#define FF_DONTCARE
Definition: wingdi.h:448
#define DEFAULT_CHARSET
Definition: wingdi.h:384

Referenced by RTFInit().

◆ ReadInfoGroup()

static void ReadInfoGroup ( RTF_Info info)
static

Definition at line 1194 of file reader.c.

1195{
1197 RTFRouteToken (info); /* feed "}" back to router */
1198}

Referenced by RTFInit().

◆ ReadObjGroup()

static void ReadObjGroup ( RTF_Info info)
static

Definition at line 1208 of file reader.c.

1209{
1211 RTFRouteToken (info); /* feed "}" back to router */
1212}

Referenced by RTFInit().

◆ ReadPictGroup()

static void ReadPictGroup ( RTF_Info info)
static

Definition at line 1201 of file reader.c.

1202{
1204 RTFRouteToken (info); /* feed "}" back to router */
1205}

Referenced by RTFInit().

◆ ReadStyleSheet()

static void ReadStyleSheet ( RTF_Info info)
static

Definition at line 1025 of file reader.c.

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;
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;
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 {
1067 ERR("skipping optional destination\n");
1069 info->rtfClass = rtfGroup;
1070 info->rtfMajor = rtfEndGroup;
1071 real_style = FALSE;
1072 break; /* ignore "\*" */
1073 }
1075 {
1076 sp->rtfSNum = info->rtfParam;
1077 sp->rtfSType = rtfParStyle;
1078 continue;
1079 }
1081 {
1082 sp->rtfSNum = info->rtfParam;
1083 sp->rtfSType = rtfCharStyle;
1084 continue;
1085 }
1087 {
1088 sp->rtfSNum = info->rtfParam;
1089 sp->rtfSType = rtfSectStyle;
1090 continue;
1091 }
1093 {
1094 sp->rtfSBasedOn = info->rtfParam;
1095 continue;
1096 }
1098 {
1099 sp->rtfSAdditive = 1;
1100 continue;
1101 }
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 }
1128 {
1129 /*
1130 * This passes over "{\*\keycode ... }, among
1131 * other things. A temporary (perhaps) hack.
1132 */
1133 ERR("skipping begin\n");
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 */
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);
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 strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
int RTFCheckMM(const RTF_Info *info, int major, int minor)
Definition: reader.c:2288
static const WCHAR sp[]
Definition: suminfo.c:287
#define rtfStyleAttr
Definition: rtf.h:271
#define rtfSectAttr
Definition: rtf.h:358
#define rtfAdditive
Definition: rtf.h:272
#define rtfNext
Definition: rtf.h:274
#define rtfNormalStyleNum
Definition: rtf.h:71
#define rtfBasedOn
Definition: rtf.h:273
#define rtfSectStyle
Definition: rtf.h:944
#define rtfNoStyleNum
Definition: rtf.h:70
#define rtfSectStyleNum
Definition: rtf.h:363
#define rtfParStyle
Definition: rtf.h:942
#define rtfCharStyle
Definition: rtf.h:943
#define rtfOptDest
Definition: rtf.h:260
#define rtfStyleNum
Definition: rtf.h:457
#define rtfCharStyleNum
Definition: rtf.h:595
int rtfSEMinor
Definition: rtf.h:1006
char * rtfSEText
Definition: rtf.h:1008
int rtfSEParam
Definition: rtf.h:1007
RTFStyleElt * rtfNextSE
Definition: rtf.h:1009
int rtfSEClass
Definition: rtf.h:1004
int rtfSEMajor
Definition: rtf.h:1005
Definition: rtf.h:989

Referenced by RTFInit().

◆ RTFCharSetToCodePage()

int RTFCharSetToCodePage ( RTF_Info info,
int  charset 
)

Definition at line 493 of file reader.c.

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;
514 return 950;
515 case GREEK_CHARSET:
516 return 1253;
517 case TURKISH_CHARSET:
518 return 1254;
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;
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 */
543 ERR("unknown charset %d\n", charset);
544 else
545 return csi.ciACP;
546 }
547 }
548 return 0;
549}
CFF_Charset charset
Definition: cffcmap.c:138
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble n
Definition: glext.h:7729
#define RUSSIAN_CHARSET
Definition: wingdi.h:396
#define ARABIC_CHARSET
Definition: wingdi.h:394
#define HANGEUL_CHARSET
Definition: wingdi.h:387
#define THAI_CHARSET
Definition: wingdi.h:397
#define GREEK_CHARSET
Definition: wingdi.h:391
#define JOHAB_CHARSET
Definition: wingdi.h:401
#define CHINESEBIG5_CHARSET
Definition: wingdi.h:390
#define ANSI_CHARSET
Definition: wingdi.h:383
#define TCI_SRCCHARSET
Definition: wingdi.h:961
#define OEM_CHARSET
Definition: wingdi.h:400
#define VIETNAMESE_CHARSET
Definition: wingdi.h:402
#define MAC_CHARSET
Definition: wingdi.h:403
#define HEBREW_CHARSET
Definition: wingdi.h:393
#define SHIFTJIS_CHARSET
Definition: wingdi.h:386
BOOL WINAPI TranslateCharsetInfo(_Inout_ PDWORD, _Out_ LPCHARSETINFO, _In_ DWORD)
#define SYMBOL_CHARSET
Definition: wingdi.h:385
#define EASTEUROPE_CHARSET
Definition: wingdi.h:399
#define GB2312_CHARSET
Definition: wingdi.h:389
#define BALTIC_CHARSET
Definition: wingdi.h:395
#define TURKISH_CHARSET
Definition: wingdi.h:392
#define CP_OEMCP
Definition: winnls.h:233
#define CP_SYMBOL
Definition: winnls.h:236
#define CP_MACCP
Definition: winnls.h:234

Referenced by ME_StreamOutRTFCharProps(), and ReadFontTbl().

◆ RTFCharToHex()

int RTFCharToHex ( char  c)

Definition at line 2297 of file reader.c.

2298{
2299 if (isupper (c))
2300 c = tolower (c);
2301 if (isdigit (c))
2302 return (c - '0'); /* '0'..'9' */
2303 return (c - 'a' + 10); /* 'a'..'f' */
2304}
#define isupper(c)
Definition: acclib.h:71
int tolower(int c)
Definition: utclib.c:902

Referenced by _RTFGetToken2(), and read_hex_data().

◆ RTFCheckCM()

int RTFCheckCM ( const RTF_Info info,
int  class,
int  major 
)

Definition at line 2276 of file reader.c.

2277{
2278 return (info->rtfClass == class && info->rtfMajor == major);
2279}
#define major(rdev)
Definition: propsheet.cpp:928

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

◆ RTFCheckCMM()

int RTFCheckCMM ( const RTF_Info info,
int  class,
int  major,
int  minor 
)

Definition at line 2282 of file reader.c.

2283{
2284 return (info->rtfClass == class && info->rtfMajor == major && info->rtfMinor == minor);
2285}
#define minor(rdev)
Definition: propsheet.cpp:929

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

◆ RTFCheckMM()

int RTFCheckMM ( const RTF_Info info,
int  major,
int  minor 
)

Definition at line 2288 of file reader.c.

2289{
2290 return (info->rtfMajor == major && info->rtfMinor == minor);
2291}

Referenced by ME_RTFReadPictGroup(), and ReadStyleSheet().

◆ RTFDestroy()

void RTFDestroy ( RTF_Info info)

Definition at line 161 of file reader.c.

162{
163 if (info->rtfTextBuf)
164 {
165 heap_free(info->rtfTextBuf);
166 heap_free(info->pushedTextBuf);
167 }
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
Definition: rtf.h:1026
RTFTable * parent
Definition: rtf.h:1044

Referenced by ME_StreamIn().

◆ RTFDestroyAttrs()

static void RTFDestroyAttrs ( RTF_Info info)
static

Definition at line 122 of file reader.c.

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}

Referenced by RTFDestroy(), and RTFInit().

◆ RTFFlushCPOutputBuffer()

static void RTFFlushCPOutputBuffer ( RTF_Info info)
static

Definition at line 2611 of file reader.c.

2612{
2613 int bufferMax = info->dwCPOutputCount * 2 * sizeof(WCHAR);
2614 WCHAR *buffer = heap_alloc(bufferMax);
2615 int length;
2616
2617 length = MultiByteToWideChar(info->codePage, 0, info->cpOutputBuffer,
2618 info->dwCPOutputCount, buffer, bufferMax/sizeof(WCHAR));
2619 info->dwCPOutputCount = 0;
2620
2623}
#define MultiByteToWideChar
Definition: compat.h:110
static void RTFPutUnicodeString(RTF_Info *info, const WCHAR *string, int length)
Definition: reader.c:2593
GLuint buffer
Definition: glext.h:5915
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
__wchar_t WCHAR
Definition: xmlstorage.h:180

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

◆ RTFFlushOutputBuffer()

void RTFFlushOutputBuffer ( RTF_Info info)

Definition at line 2626 of file reader.c.

2627{
2628 if (info->dwCPOutputCount)
2631}
static void RTFFlushCPOutputBuffer(RTF_Info *info)
Definition: reader.c:2611
static void RTFFlushUnicodeOutputBuffer(RTF_Info *info)
Definition: reader.c:2581

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

◆ RTFFlushUnicodeOutputBuffer()

static void RTFFlushUnicodeOutputBuffer ( RTF_Info info)
static

Definition at line 2581 of file reader.c.

2582{
2583 if (info->dwOutputCount)
2584 {
2585 ME_InsertTextFromCursor(info->editor, 0, info->OutputBuffer,
2586 info->dwOutputCount, info->style);
2587 info->dwOutputCount = 0;
2588 }
2589}
void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor, const WCHAR *str, int len, ME_Style *style)
Definition: caret.c:595

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

◆ RTFGetClassCallback()

static RTFFuncPtr RTFGetClassCallback ( const RTF_Info info,
int  class 
)
static

Definition at line 198 of file reader.c.

199{
200 if (class >= 0 && class < rtfMaxClass)
201 return info->ccb[class];
202 return NULL;
203}
#define rtfMaxClass
Definition: rtf.h:83

Referenced by RTFRouteToken().

◆ RTFGetColor()

RTFColor * RTFGetColor ( const RTF_Info info,
int  num 
)

Definition at line 1237 of file reader.c.

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}
GLuint GLuint num
Definition: glext.h:9618

Referenced by ME_RTFCharAttrHook().

◆ RTFGetDestinationCallback()

static RTFFuncPtr RTFGetDestinationCallback ( const RTF_Info info,
int  dest 
)
static

Definition at line 288 of file reader.c.

289{
290 if (dest >= 0 && dest < rtfMaxDestination)
291 return info->dcb[dest];
292 return NULL;
293}
static char * dest
Definition: rtl.c:135
#define rtfMaxDestination
Definition: rtf.h:189

Referenced by Destination(), and RTFRouteToken().

◆ RTFGetFont()

RTFFont * RTFGetFont ( const RTF_Info info,
int  num 
)

Definition at line 1222 of file reader.c.

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}
GLfloat f
Definition: glext.h:7540
#define f
Definition: ke_i.h:83

Referenced by CharAttr(), and ME_RTFCharAttrHook().

◆ RTFGetReadHook()

static RTFFuncPtr RTFGetReadHook ( const RTF_Info info)
static

Definition at line 394 of file reader.c.

395{
396 return (info->readHook);
397}

Referenced by RTFGetToken().

◆ RTFGetToken()

int RTFGetToken ( RTF_Info info)

Definition at line 406 of file reader.c.

407{
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 {
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 void _RTFGetToken(RTF_Info *)
Definition: reader.c:454
static RTFFuncPtr RTFGetReadHook(const RTF_Info *info)
Definition: reader.c:394
GLfloat GLfloat p
Definition: glext.h:8902
void(* RTFFuncPtr)(RTF_Info *)
Definition: rtf.h:1095

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

◆ RTFInit()

void RTFInit ( RTF_Info info)

Definition at line 212 of file reader.c.

213{
214 int i;
215
216 if (info->rtfTextBuf == NULL) /* initialize the text buffers */
217 {
218 info->rtfTextBuf = heap_alloc (rtfBufSiz);
219 info->pushedTextBuf = 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++)
229 for (i = 0; i < rtfMaxDestination; i++)
231
232 /* install built-in destination readers */
239
240
242
243 /* dump old lists if necessary */
244
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;
265 info->cpOutputBuffer = heap_alloc(info->dwMaxCPOutputCount);
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}
static void ReadInfoGroup(RTF_Info *)
Definition: reader.c:1194
static void ReadFontTbl(RTF_Info *)
Definition: reader.c:786
static void ReadColorTbl(RTF_Info *)
Definition: reader.c:965
static void ReadPictGroup(RTF_Info *)
Definition: reader.c:1201
static void ReadStyleSheet(RTF_Info *)
Definition: reader.c:1025
void RTFSetReadHook(RTF_Info *info, RTFFuncPtr f)
Definition: reader.c:388
static void ReadObjGroup(RTF_Info *)
Definition: reader.c:1208
void RTFSetDestinationCallback(RTF_Info *info, int dest, RTFFuncPtr callback)
Definition: reader.c:281
#define rtfFontTbl
Definition: rtf.h:110
#define rtfObject
Definition: rtf.h:155
#define rtfStyleSheet
Definition: rtf.h:117
#define rtfInfo
Definition: rtf.h:120
#define rtfPict
Definition: rtf.h:154
#define rtfColorTbl
Definition: rtf.h:116

Referenced by ME_StreamIn().

◆ RTFPutCodePageChar()

static void RTFPutCodePageChar ( RTF_Info info,
int  c 
)
static

Definition at line 2644 of file reader.c.

2645{
2646 /* Use dynamic buffer here because it's the best way to handle
2647 * MBCS codepages without having to worry about partial chars */
2648 if (info->dwCPOutputCount >= info->dwMaxCPOutputCount)
2649 {
2650 info->dwMaxCPOutputCount *= 2;
2651 info->cpOutputBuffer = heap_realloc(info->cpOutputBuffer, info->dwMaxCPOutputCount);
2652 }
2653 info->cpOutputBuffer[info->dwCPOutputCount++] = c;
2654}

Referenced by TextClass().

◆ RTFPutUnicodeChar()

static void RTFPutUnicodeChar ( RTF_Info info,
int  c 
)
static

Definition at line 2634 of file reader.c.

2635{
2636 if (info->dwCPOutputCount)
2638 if (info->dwOutputCount * sizeof(WCHAR) >= ( sizeof info->OutputBuffer - 1 ) )
2640 info->OutputBuffer[info->dwOutputCount++] = c;
2641}

Referenced by SpecialChar().

◆ RTFPutUnicodeString()

static void RTFPutUnicodeString ( RTF_Info info,
const WCHAR string,
int  length 
)
static

Definition at line 2593 of file reader.c.

2594{
2595 if (info->dwCPOutputCount)
2597 while (length)
2598 {
2599 int fit = min(length, ARRAY_SIZE(info->OutputBuffer) - info->dwOutputCount);
2600
2601 memmove(info->OutputBuffer + info->dwOutputCount, string, fit * sizeof(WCHAR));
2602 info->dwOutputCount += fit;
2603 length -= fit;
2604 string += fit;
2605 if (ARRAY_SIZE(info->OutputBuffer) == info->dwOutputCount)
2607 }
2608}
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define min(a, b)
Definition: monoChain.cc:55

Referenced by RTFFlushCPOutputBuffer().

◆ RTFRead()

void RTFRead ( RTF_Info info)

Definition at line 308 of file reader.c.

309{
310 while (RTFGetToken (info) != rtfEOF)
312}

Referenced by ME_StreamIn().

◆ RTFReadGroup()

void RTFReadGroup ( RTF_Info info)

Definition at line 379 of file reader.c.

380{
381}

Referenced by ME_StreamIn().

◆ RTFRouteToken()

void RTFRouteToken ( RTF_Info info)

Definition at line 321 of file reader.c.

322{
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 }
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}
static RTFFuncPtr RTFGetClassCallback(const RTF_Info *info, int class)
Definition: reader.c:198

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

◆ RTFSetClassCallback()

static void RTFSetClassCallback ( RTF_Info info,
int  class,
RTFFuncPtr  callback 
)
static

Definition at line 191 of file reader.c.

192{
193 if (class >= 0 && class < rtfMaxClass)
194 info->ccb[class] = callback;
195}
static IPrintDialogCallback callback
Definition: printdlg.c:326

Referenced by BeginFile(), and RTFInit().

◆ RTFSetDestinationCallback()

void RTFSetDestinationCallback ( RTF_Info info,
int  dest,
RTFFuncPtr  callback 
)

Definition at line 281 of file reader.c.

282{
283 if (dest >= 0 && dest < rtfMaxDestination)
284 info->dcb[dest] = callback;
285}

Referenced by ME_StreamIn(), and RTFInit().

◆ RTFSetEditStream()

void RTFSetEditStream ( RTF_Info info,
ME_InStream stream 
)

Definition at line 116 of file reader.c.

117{
118 info->stream = stream;
119}

Referenced by ME_StreamIn().

◆ RTFSetReadHook()

void RTFSetReadHook ( RTF_Info info,
RTFFuncPtr  f 
)

Definition at line 388 of file reader.c.

389{
390 info->readHook = f;
391}

Referenced by ME_StreamIn(), and RTFInit().

◆ RTFSkipGroup()

void RTFSkipGroup ( RTF_Info info)

Definition at line 354 of file reader.c.

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

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

◆ RTFStrSave()

static char * RTFStrSave ( const char s)
inlinestatic

Definition at line 81 of file reader.c.

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}

Referenced by ReadFontTbl(), and ReadStyleSheet().

◆ RTFUngetToken()

static void RTFUngetToken ( RTF_Info info)
static

Definition at line 431 of file reader.c.

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. */
446 {
447 info->stack[info->stackTop].style = info->style;
448 ME_AddRefStyle(info->style);
449 info->stackTop++;
450 }
451}
void ME_AddRefStyle(ME_Style *item) DECLSPEC_HIDDEN
Definition: style.c:454

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

◆ SpecialChar()

static void SpecialChar ( RTF_Info info)
static

Definition at line 2481 of file reader.c.

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

Referenced by ControlClass().

◆ TextClass()

static void TextClass ( RTF_Info info)
static

Definition at line 2350 of file reader.c.

2351{
2352 RTFPutCodePageChar(info, info->rtfMajor);
2353}
static void RTFPutCodePageChar(RTF_Info *info, int c)
Definition: reader.c:2644

Referenced by BeginFile().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( richedit  )

◆ WriterInit()

void WriterInit ( RTF_Info info)

Definition at line 2329 of file reader.c.

2330{
2331}

Referenced by ME_StreamIn().

Variable Documentation

◆ rtfHashTable

RTFHashTableEntry rtfHashTable[ARRAY_SIZE(rtfKey) *2]
static

Definition at line 2184 of file reader.c.

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

◆ rtfKey

RTFKey rtfKey[]
static

Definition at line 1274 of file reader.c.

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