From 9a559774142e17adc79d9dcf3c4ca5a61d91da3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Sun, 1 Feb 2004 21:20:05 +0000 Subject: [PATCH] Sync richedit with WineHQ svn path=/trunk/; revision=7978 --- reactos/doc/README.WINE | 2 +- reactos/lib/richedit/Makefile | 17 +- reactos/lib/richedit/Makefile.in | 16 + reactos/lib/richedit/Makefile.ros-template | 19 + reactos/lib/richedit/reader.c | 1040 +++++++++----------- reactos/lib/richedit/riched32.def | 6 - reactos/lib/richedit/riched32.edf | 4 - reactos/lib/richedit/riched32.rc | 38 - reactos/lib/richedit/riched32.spec | 1 + reactos/lib/richedit/richedit.c | 173 ++-- reactos/lib/richedit/rtf.h | 234 +++-- reactos/lib/richedit/text-writer.c | 114 +-- reactos/lib/richedit/winehq2ros.patch | 0 13 files changed, 825 insertions(+), 839 deletions(-) create mode 100644 reactos/lib/richedit/Makefile.in create mode 100644 reactos/lib/richedit/Makefile.ros-template delete mode 100644 reactos/lib/richedit/riched32.def delete mode 100644 reactos/lib/richedit/riched32.edf delete mode 100644 reactos/lib/richedit/riched32.rc create mode 100644 reactos/lib/richedit/riched32.spec create mode 100644 reactos/lib/richedit/winehq2ros.patch diff --git a/reactos/doc/README.WINE b/reactos/doc/README.WINE index f7e9ef3cf13..725f565f03a 100644 --- a/reactos/doc/README.WINE +++ b/reactos/doc/README.WINE @@ -40,7 +40,7 @@ reactos/lib/imm32 reactos/lib/msvcrt20 reactos/lib/mpr # Imported 20040201 reactos/lib/ole32 # Synced to Wine-20040121 -reactos/lib/richedit #Out of sync +reactos/lib/richedit # Synced 20040201 reactos/lib/rpcrt4 #Out of date In need of new merge reactos/lib/shell32 # 2004/01/22: Heavy syncing in progress reactos/lib/shlwapi # Synced to Wine-20040121 diff --git a/reactos/lib/richedit/Makefile b/reactos/lib/richedit/Makefile index 6e06ee00b40..40780866918 100644 --- a/reactos/lib/richedit/Makefile +++ b/reactos/lib/richedit/Makefile @@ -1,20 +1,9 @@ +# $Id: Makefile,v 1.8 2004/02/01 21:20:05 gvg Exp $ + PATH_TO_TOP = ../.. -TARGET_TYPE = dynlink - -TARGET_NAME = riched32 - -TARGET_BASE = 0x76340000 - -# require os code to explicitly request A/W version of structs/functions -TARGET_CFLAGS += -DWM_ALTTABACTIVE=0x0029 -D_DISABLE_TIDENTS -D__USE_W32API -Werror -Wall - -TARGET_SDKLIBS = ntdll.a libwine.a - -TARGET_OBJECTS = charlist.o reader.o richedit.o text-writer.o +TARGET_TYPE = winedll include $(PATH_TO_TOP)/rules.mak include $(TOOLS_PATH)/helper.mk - -include $(TOOLS_PATH)/config.mk diff --git a/reactos/lib/richedit/Makefile.in b/reactos/lib/richedit/Makefile.in new file mode 100644 index 00000000000..4a1b4e94183 --- /dev/null +++ b/reactos/lib/richedit/Makefile.in @@ -0,0 +1,16 @@ +TOPSRCDIR = @top_srcdir@ +TOPOBJDIR = ../.. +SRCDIR = @srcdir@ +VPATH = @srcdir@ +MODULE = riched32.dll +IMPORTS = user32 kernel32 + +C_SRCS = \ + charlist.c \ + reader.c \ + text-writer.c \ + richedit.c + +@MAKE_DLL_RULES@ + +### Dependencies: diff --git a/reactos/lib/richedit/Makefile.ros-template b/reactos/lib/richedit/Makefile.ros-template new file mode 100644 index 00000000000..1f793c6743d --- /dev/null +++ b/reactos/lib/richedit/Makefile.ros-template @@ -0,0 +1,19 @@ +# $Id: Makefile.ros-template,v 1.1 2004/02/01 21:20:05 gvg Exp $ + +TARGET_NAME = riched32 + +TARGET_OBJECTS = @C_SRCS@ + +TARGET_CFLAGS = @EXTRADEFS@ -D__REACTOS__ + +TARGET_SDKLIBS = @IMPORTS@ libwine.a ntdll.a + +TARGET_BASE = 0x76340000 + +TARGET_NORC = yes + +default: all + +DEP_OBJECTS = $(TARGET_OBJECTS) + +include $(TOOLS_PATH)/depend.mk diff --git a/reactos/lib/richedit/reader.c b/reactos/lib/richedit/reader.c index 13e98c83e22..aaacb89bb6d 100644 --- a/reactos/lib/richedit/reader.c +++ b/reactos/lib/richedit/reader.c @@ -1,3 +1,23 @@ +/* + * WINE RTF file reader + * + * Portions Copyright 2004 Mike McCormack for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + /* * - Need to document error code meanings. * - Need to do something with \* on destinations. @@ -49,8 +69,7 @@ # include # include -# include "rtf.h" - +#include "rtf.h" /* * include hard coded charsets */ @@ -62,6 +81,7 @@ #include #include "charlist.h" + #include "windef.h" #include "winbase.h" #include "wine/debug.h" @@ -70,80 +90,24 @@ WINE_DEFAULT_DEBUG_CHANNEL(richedit); extern HANDLE RICHED32_hHeap; -/* - * Return pointer to new element of type t, or NULL - * if no memory available. - */ - -# define New(t) ((t *) RTFAlloc ((int) sizeof (t))) - -/* maximum number of character values representable in a byte */ - -# define charSetSize 256 - -/* charset stack size */ - -# define maxCSStack 10 - -static int _RTFGetChar(); -static void _RTFGetToken (); -static void _RTFGetToken2 (); -static int GetChar (); -static void ReadFontTbl (); -static void ReadColorTbl (); -static void ReadStyleSheet (); -static void ReadInfoGroup (); -static void ReadPictGroup (); -static void ReadObjGroup (); +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 LookupInit (); -static void Lookup (); +static void Lookup (RTF_Info *, char *); static int Hash (); -static void CharSetInit (); -static void ReadCharSetMaps (); +static void CharSetInit (RTF_Info *); +static void ReadCharSetMaps (RTF_Info *); -/* - * Public variables (listed in rtf.h) - */ - -int rtfClass; -int rtfMajor; -int rtfMinor; -int rtfParam; -int rtfFormat; -char *rtfTextBuf = (char *) NULL; -int rtfTextLen; - -long rtfLineNum; -int rtfLinePos; - - -/* - * Private stuff - */ - -static int pushedChar; /* pushback char if read too far */ - -static int pushedClass; /* pushed token info for RTFUngetToken() */ -static int pushedMajor; -static int pushedMinor; -static int pushedParam; -static char *pushedTextBuf = (char *) NULL; - -static int prevChar; -static int bumpLine; - -static RTFFont *fontList = (RTFFont *) NULL; /* these lists MUST be */ -static RTFColor *colorList = (RTFColor *) NULL; /* initialized to NULL */ -static RTFStyle *styleList = (RTFStyle *) NULL; - -static char *inputName = (char *) NULL; -static char *outputName = (char *) NULL; - -static EDITSTREAM editstream; -static CHARLIST inputCharList = {0, NULL, NULL}; - /* * This array is used to map standard character names onto their numeric codes. * The position of the name within the array is the code. @@ -152,74 +116,33 @@ static CHARLIST inputCharList = {0, NULL, NULL}; #include "stdcharnames.h" -/* - * These arrays are used to map RTF input character values onto the standard - * character names represented by the values. Input character values are - * used as indices into the arrays to produce standard character codes. - */ - - -static char *genCharSetFile = (char *) NULL; -static int genCharCode[charSetSize]; /* general */ -static int haveGenCharSet = 0; - -static char *symCharSetFile = (char *) NULL; -static int symCharCode[charSetSize]; /* symbol */ -static int haveSymCharSet = 0; - -static int curCharSet = rtfCSGeneral; -static int *curCharCode = genCharCode; - -/* - * By default, the reader is configured to handle charset mapping invisibly, - * including reading the charset files and switching charset maps as necessary - * for Symbol font. - */ - -static int autoCharSetFlags; - -/* - * Stack for keeping track of charset map on group begin/end. This is - * necessary because group termination reverts the font to the previous - * value, which may implicitly change it. - */ - -static int csStack[maxCSStack]; -static int csTop = 0; - -/* - * Get a char from the charlist. The charlist is used to store characters - * from the editstream. - * - */ - -int _RTFGetChar(void) +int _RTFGetChar(RTF_Info *info) { char myChar; TRACE("\n"); - if(CHARLIST_GetNbItems(&inputCharList) == 0) + if(CHARLIST_GetNbItems(&info->inputCharList) == 0) { char buff[10]; long pcb; - editstream.pfnCallback(editstream.dwCookie, buff, 1, &pcb); + info->editstream.pfnCallback(info->editstream.dwCookie, buff, 1, &pcb); if(pcb == 0) return EOF; else - CHARLIST_Enqueue(&inputCharList, buff[0]); + CHARLIST_Enqueue(&info->inputCharList, buff[0]); } - myChar = CHARLIST_Dequeue(&inputCharList); + myChar = CHARLIST_Dequeue(&info->inputCharList); return (int) myChar; } -void RTFSetEditStream(EDITSTREAM *es) +void RTFSetEditStream(RTF_Info *info, EDITSTREAM *es) { TRACE("\n"); - editstream.dwCookie = es->dwCookie; - editstream.dwError = es->dwError; - editstream.pfnCallback = es->pfnCallback; + info->editstream.dwCookie = es->dwCookie; + info->editstream.dwError = es->dwError; + info->editstream.pfnCallback = es->pfnCallback; } /* @@ -228,7 +151,7 @@ void RTFSetEditStream(EDITSTREAM *es) * stream; that must be done with RTFSetStream(). */ -void RTFInit(void) +void RTFInit(RTF_Info *info) { int i; RTFColor *cp; @@ -238,58 +161,58 @@ RTFStyleElt *eltList, *ep; TRACE("\n"); - if (rtfTextBuf == (char *) NULL) /* initialize the text buffers */ + if (info->rtfTextBuf == (char *) NULL) /* initialize the text buffers */ { - rtfTextBuf = RTFAlloc (rtfBufSiz); - pushedTextBuf = RTFAlloc (rtfBufSiz); - if (rtfTextBuf == (char *) NULL - || pushedTextBuf == (char *) NULL) - RTFPanic ("Cannot allocate text buffers."); - rtfTextBuf[0] = pushedTextBuf[0] = '\0'; + info->rtfTextBuf = RTFAlloc (rtfBufSiz); + info->pushedTextBuf = RTFAlloc (rtfBufSiz); + if (info->rtfTextBuf == (char *) NULL + || info->pushedTextBuf == (char *) NULL) + RTFPanic (info,"Cannot allocate text buffers."); + info->rtfTextBuf[0] = info->pushedTextBuf[0] = '\0'; } - RTFFree (inputName); - RTFFree (outputName); - inputName = outputName = (char *) NULL; + RTFFree (info->inputName); + RTFFree (info->outputName); + info->inputName = info->outputName = (char *) NULL; /* initialize lookup table */ LookupInit (); for (i = 0; i < rtfMaxClass; i++) - RTFSetClassCallback (i, (RTFFuncPtr) NULL); + RTFSetClassCallback (info, i, (RTFFuncPtr) NULL); for (i = 0; i < rtfMaxDestination; i++) - RTFSetDestinationCallback (i, (RTFFuncPtr) NULL); + RTFSetDestinationCallback (info, i, (RTFFuncPtr) NULL); /* install built-in destination readers */ - RTFSetDestinationCallback (rtfFontTbl, ReadFontTbl); - RTFSetDestinationCallback (rtfColorTbl, ReadColorTbl); - RTFSetDestinationCallback (rtfStyleSheet, ReadStyleSheet); - RTFSetDestinationCallback (rtfInfo, ReadInfoGroup); - RTFSetDestinationCallback (rtfPict, ReadPictGroup); - RTFSetDestinationCallback (rtfObject, ReadObjGroup); + RTFSetDestinationCallback (info, rtfFontTbl, ReadFontTbl); + RTFSetDestinationCallback (info, rtfColorTbl, ReadColorTbl); + RTFSetDestinationCallback (info, rtfStyleSheet, ReadStyleSheet); + RTFSetDestinationCallback (info, rtfInfo, ReadInfoGroup); + RTFSetDestinationCallback (info, rtfPict, ReadPictGroup); + RTFSetDestinationCallback (info, rtfObject, ReadObjGroup); - RTFSetReadHook ((RTFFuncPtr) NULL); + RTFSetReadHook (info, (RTFFuncPtr) NULL); /* dump old lists if necessary */ - while (fontList != (RTFFont *) NULL) + while (info->fontList != (RTFFont *) NULL) { - fp = fontList->rtfNextFont; - RTFFree (fontList->rtfFName); - RTFFree ((char *) fontList); - fontList = fp; + fp = info->fontList->rtfNextFont; + RTFFree (info->fontList->rtfFName); + RTFFree ((char *) info->fontList); + info->fontList = fp; } - while (colorList != (RTFColor *) NULL) + while (info->colorList != (RTFColor *) NULL) { - cp = colorList->rtfNextColor; - RTFFree ((char *) colorList); - colorList = cp; + cp = info->colorList->rtfNextColor; + RTFFree ((char *) info->colorList); + info->colorList = cp; } - while (styleList != (RTFStyle *) NULL) + while (info->styleList != (RTFStyle *) NULL) { - sp = styleList->rtfNextStyle; - eltList = styleList->rtfSSEList; + sp = info->styleList->rtfNextStyle; + eltList = info->styleList->rtfSSEList; while (eltList != (RTFStyleElt *) NULL) { ep = eltList->rtfNextSE; @@ -297,22 +220,22 @@ RTFStyleElt *eltList, *ep; RTFFree ((char *) eltList); eltList = ep; } - RTFFree (styleList->rtfSName); - RTFFree ((char *) styleList); - styleList = sp; + RTFFree (info->styleList->rtfSName); + RTFFree ((char *) info->styleList); + info->styleList = sp; } - rtfClass = -1; - pushedClass = -1; - pushedChar = EOF; + info->rtfClass = -1; + info->pushedClass = -1; + info->pushedChar = EOF; - rtfLineNum = 0; - rtfLinePos = 0; - prevChar = EOF; - bumpLine = 0; + info->rtfLineNum = 0; + info->rtfLinePos = 0; + info->prevChar = EOF; + info->bumpLine = 0; - CharSetInit (); - csTop = 0; + CharSetInit (info); + info->csTop = 0; } /* @@ -320,33 +243,33 @@ RTFStyleElt *eltList, *ep; * to be accurate, only insofar as the calling program makes them so. */ -void RTFSetInputName(char *name) +void RTFSetInputName(RTF_Info *info, char *name) { TRACE("\n"); - if ((inputName = RTFStrSave (name)) == (char *) NULL) - RTFPanic ("RTFSetInputName: out of memory"); + if ((info->inputName = RTFStrSave (name)) == (char *) NULL) + RTFPanic (info,"RTFSetInputName: out of memory"); } -char *RTFGetInputName(void) +char *RTFGetInputName(RTF_Info *info) { - return (inputName); + return (info->inputName); } -void RTFSetOutputName(char *name) +void RTFSetOutputName(RTF_Info *info, char *name) { TRACE("\n"); - if ((outputName = RTFStrSave (name)) == (char *) NULL) - RTFPanic ("RTFSetOutputName: out of memory"); + if ((info->outputName = RTFStrSave (name)) == (char *) NULL) + RTFPanic (info, "RTFSetOutputName: out of memory"); } -char *RTFGetOutputName(void) +char *RTFGetOutputName(RTF_Info *info) { - return (outputName); + return (info->outputName); } @@ -362,21 +285,17 @@ char *RTFGetOutputName(void) * Install or return a writer callback for a token class */ - -static RTFFuncPtr ccb[rtfMaxClass]; /* class callbacks */ - - -void RTFSetClassCallback(int class, RTFFuncPtr callback) +void RTFSetClassCallback(RTF_Info *info, int class, RTFFuncPtr callback) { if (class >= 0 && class < rtfMaxClass) - ccb[class] = callback; + info->ccb[class] = callback; } -RTFFuncPtr RTFGetClassCallback(int class) +RTFFuncPtr RTFGetClassCallback(RTF_Info *info, int class) { if (class >= 0 && class < rtfMaxClass) - return (ccb[class]); + return (info->ccb[class]); return ((RTFFuncPtr) NULL); } @@ -385,20 +304,17 @@ RTFFuncPtr RTFGetClassCallback(int class) * Install or return a writer callback for a destination type */ -static RTFFuncPtr dcb[rtfMaxDestination]; /* destination callbacks */ - - -void RTFSetDestinationCallback(int dest, RTFFuncPtr callback) +void RTFSetDestinationCallback(RTF_Info *info, int dest, RTFFuncPtr callback) { if (dest >= 0 && dest < rtfMaxDestination) - dcb[dest] = callback; + info->dcb[dest] = callback; } -RTFFuncPtr RTFGetDestinationCallback(int dest) +RTFFuncPtr RTFGetDestinationCallback(RTF_Info *info, int dest) { if (dest >= 0 && dest < rtfMaxDestination) - return (dcb[dest]); + return (info->dcb[dest]); return ((RTFFuncPtr) NULL); } @@ -415,10 +331,10 @@ RTFFuncPtr RTFGetDestinationCallback(int dest) * where appropriate. */ -void RTFRead(void) +void RTFRead(RTF_Info *info) { - while (RTFGetToken () != rtfEOF) - RTFRouteToken (); + while (RTFGetToken (info) != rtfEOF) + RTFRouteToken (info); } @@ -428,30 +344,30 @@ void RTFRead(void) * pass the token to the writer's class callback. */ -void RTFRouteToken(void) +void RTFRouteToken(RTF_Info *info) { RTFFuncPtr p; TRACE("\n"); - if (rtfClass < 0 || rtfClass >= rtfMaxClass) /* watchdog */ + if (info->rtfClass < 0 || info->rtfClass >= rtfMaxClass) /* watchdog */ { - RTFPanic ("Unknown class %d: %s (reader malfunction)", - rtfClass, rtfTextBuf); + RTFPanic (info,"Unknown class %d: %s (reader malfunction)", + info->rtfClass, info->rtfTextBuf); } - if (RTFCheckCM (rtfControl, rtfDestination)) + if (RTFCheckCM (info, rtfControl, rtfDestination)) { /* invoke destination-specific callback if there is one */ - if ((p = RTFGetDestinationCallback (rtfMinor)) + if ((p = RTFGetDestinationCallback (info, info->rtfMinor)) != (RTFFuncPtr) NULL) { - (*p) (); + (*p) (info); return; } } /* invoke class callback if there is one */ - if ((p = RTFGetClassCallback (rtfClass)) != (RTFFuncPtr) NULL) - (*p) (); + if ((p = RTFGetClassCallback (info, info->rtfClass)) != (RTFFuncPtr) NULL) + (*p) (info); } @@ -462,18 +378,18 @@ RTFFuncPtr p; * closing brace. */ -void RTFSkipGroup(void) +void RTFSkipGroup(RTF_Info *info) { int level = 1; TRACE("\n"); - while (RTFGetToken () != rtfEOF) + while (RTFGetToken (info) != rtfEOF) { - if (rtfClass == rtfGroup) + if (info->rtfClass == rtfGroup) { - if (rtfMajor == rtfBeginGroup) + if (info->rtfMajor == rtfBeginGroup) ++level; - else if (rtfMajor == rtfEndGroup) + else if (info->rtfMajor == rtfEndGroup) { if (--level < 1) break; /* end of initial group */ @@ -489,23 +405,23 @@ int level = 1; * are no more tokens. */ -int RTFGetToken(void) +int RTFGetToken(RTF_Info *info) { RTFFuncPtr p; TRACE("\n"); for (;;) { - _RTFGetToken (); - if ((p = RTFGetReadHook ()) != (RTFFuncPtr) NULL) - (*p) (); /* give read hook a look at token */ + _RTFGetToken (info); + if ((p = RTFGetReadHook (info)) != (RTFFuncPtr) NULL) + (*p) (info); /* give read hook a look at token */ /* Silently discard newlines, carriage returns, nulls. */ - if (!(rtfClass == rtfText && rtfFormat != SF_TEXT - && (rtfMajor == '\r' || rtfMajor == '\n' || rtfMajor == '\0'))) + if (!(info->rtfClass == rtfText && info->rtfFormat != SF_TEXT + && (info->rtfMajor == '\r' || info->rtfMajor == '\n' || info->rtfMajor == '\0'))) break; } - return (rtfClass); + return (info->rtfClass); } @@ -513,74 +429,71 @@ RTFFuncPtr p; * Install or return a token reader hook. */ -static RTFFuncPtr readHook; - - -void RTFSetReadHook(RTFFuncPtr f) +void RTFSetReadHook(RTF_Info *info, RTFFuncPtr f) { - readHook = f; + info->readHook = f; } -RTFFuncPtr RTFGetReadHook(void) +RTFFuncPtr RTFGetReadHook(RTF_Info *info) { - return (readHook); + return (info->readHook); } -void RTFUngetToken(void) +void RTFUngetToken(RTF_Info *info) { TRACE("\n"); - if (pushedClass >= 0) /* there's already an ungotten token */ - RTFPanic ("cannot unget two tokens"); - if (rtfClass < 0) - RTFPanic ("no token to unget"); - pushedClass = rtfClass; - pushedMajor = rtfMajor; - pushedMinor = rtfMinor; - pushedParam = rtfParam; - (void) strcpy (pushedTextBuf, rtfTextBuf); + if (info->pushedClass >= 0) /* there's already an ungotten token */ + RTFPanic (info,"cannot unget two tokens"); + if (info->rtfClass < 0) + RTFPanic (info,"no token to unget"); + info->pushedClass = info->rtfClass; + info->pushedMajor = info->rtfMajor; + info->pushedMinor = info->rtfMinor; + info->pushedParam = info->rtfParam; + (void) strcpy (info->pushedTextBuf, info->rtfTextBuf); } -int RTFPeekToken(void) +int RTFPeekToken(RTF_Info *info) { - _RTFGetToken (); - RTFUngetToken (); - return (rtfClass); + _RTFGetToken (info); + RTFUngetToken (info); + return (info->rtfClass); } -static void _RTFGetToken(void) +static void _RTFGetToken(RTF_Info *info) { RTFFont *fp; TRACE("\n"); - if (rtfFormat == SF_TEXT) { - rtfMajor = GetChar (); - rtfMinor = rtfSC_nothing; - rtfParam = rtfNoParam; - rtfTextBuf[rtfTextLen = 0] = '\0'; - if (rtfMajor == EOF) - rtfClass = rtfEOF; + if (info->rtfFormat == SF_TEXT) { + info->rtfMajor = GetChar (info); + info->rtfMinor = rtfSC_nothing; + info->rtfParam = rtfNoParam; + info->rtfTextBuf[info->rtfTextLen = 0] = '\0'; + if (info->rtfMajor == EOF) + info->rtfClass = rtfEOF; else - rtfClass = rtfText; + info->rtfClass = rtfText; return; } /* first check for pushed token from RTFUngetToken() */ - if (pushedClass >= 0) + if (info->pushedClass >= 0) { - rtfClass = pushedClass; - rtfMajor = pushedMajor; - rtfMinor = pushedMinor; - rtfParam = pushedParam; - (void) strcpy (rtfTextBuf, pushedTextBuf); - rtfTextLen = strlen (rtfTextBuf); - pushedClass = -1; + info->rtfClass = info->pushedClass; + info->rtfMajor = info->pushedMajor; + info->rtfMinor = info->pushedMinor; + info->rtfParam = info->pushedParam; + (void) strcpy (info->rtfTextBuf, info->pushedTextBuf); + info->rtfTextLen = strlen (info->rtfTextBuf); + info->pushedClass = -1; return; } @@ -589,49 +502,49 @@ RTFFont *fp; * important, e.g., for making sure no "}" pops the font stack twice. */ - _RTFGetToken2 (); - if (rtfClass == rtfText) /* map RTF char to standard code */ - rtfMinor = RTFMapChar (rtfMajor); + _RTFGetToken2 (info); + if (info->rtfClass == rtfText) /* map RTF char to standard code */ + info->rtfMinor = RTFMapChar (info, info->rtfMajor); /* * If auto-charset stuff is activated, see if anything needs doing, * like reading the charset maps or switching between them. */ - if (autoCharSetFlags == 0) + if (info->autoCharSetFlags == 0) return; - if ((autoCharSetFlags & rtfReadCharSet) - && RTFCheckCM (rtfControl, rtfCharSet)) + if ((info->autoCharSetFlags & rtfReadCharSet) + && RTFCheckCM (info, rtfControl, rtfCharSet)) { - ReadCharSetMaps (); + ReadCharSetMaps (info); } - else if ((autoCharSetFlags & rtfSwitchCharSet) - && RTFCheckCMM (rtfControl, rtfCharAttr, rtfFontNum)) + else if ((info->autoCharSetFlags & rtfSwitchCharSet) + && RTFCheckCMM (info, rtfControl, rtfCharAttr, rtfFontNum)) { - if ((fp = RTFGetFont (rtfParam)) != (RTFFont *) NULL) + if ((fp = RTFGetFont (info, info->rtfParam)) != (RTFFont *) NULL) { if (strncmp (fp->rtfFName, "Symbol", 6) == 0) - curCharSet = rtfCSSymbol; + info->curCharSet = rtfCSSymbol; else - curCharSet = rtfCSGeneral; - RTFSetCharSet (curCharSet); + info->curCharSet = rtfCSGeneral; + RTFSetCharSet (info, info->curCharSet); } } - else if ((autoCharSetFlags & rtfSwitchCharSet) && rtfClass == rtfGroup) + else if ((info->autoCharSetFlags & rtfSwitchCharSet) && info->rtfClass == rtfGroup) { - switch (rtfMajor) + switch (info->rtfMajor) { case rtfBeginGroup: - if (csTop >= maxCSStack) - RTFPanic ("_RTFGetToken: stack overflow"); - csStack[csTop++] = curCharSet; + if (info->csTop >= maxCSStack) + RTFPanic (info, "_RTFGetToken: stack overflow"); + info->csStack[info->csTop++] = info->curCharSet; break; case rtfEndGroup: - if (csTop <= 0) - RTFPanic ("_RTFGetToken: stack underflow"); - curCharSet = csStack[--csTop]; - RTFSetCharSet (curCharSet); + if (info->csTop <= 0) + RTFPanic (info,"_RTFGetToken: stack underflow"); + info->curCharSet = info->csStack[--info->csTop]; + RTFSetCharSet (info, info->curCharSet); break; } } @@ -640,7 +553,7 @@ RTFFont *fp; /* this shouldn't be called anywhere but from _RTFGetToken() */ -static void _RTFGetToken2(void) +static void _RTFGetToken2(RTF_Info *info) { int sign; int c; @@ -649,35 +562,35 @@ int c; /* initialize token vars */ - rtfClass = rtfUnknown; - rtfParam = rtfNoParam; - rtfTextBuf[rtfTextLen = 0] = '\0'; + info->rtfClass = rtfUnknown; + info->rtfParam = rtfNoParam; + info->rtfTextBuf[info->rtfTextLen = 0] = '\0'; /* get first character, which may be a pushback from previous token */ - if (pushedChar != EOF) + if (info->pushedChar != EOF) { - c = pushedChar; - rtfTextBuf[rtfTextLen++] = c; - rtfTextBuf[rtfTextLen] = '\0'; - pushedChar = EOF; + c = info->pushedChar; + info->rtfTextBuf[info->rtfTextLen++] = c; + info->rtfTextBuf[info->rtfTextLen] = '\0'; + info->pushedChar = EOF; } - else if ((c = GetChar ()) == EOF) + else if ((c = GetChar (info)) == EOF) { - rtfClass = rtfEOF; + info->rtfClass = rtfEOF; return; } if (c == '{') { - rtfClass = rtfGroup; - rtfMajor = rtfBeginGroup; + info->rtfClass = rtfGroup; + info->rtfMajor = rtfBeginGroup; return; } if (c == '}') { - rtfClass = rtfGroup; - rtfMajor = rtfEndGroup; + info->rtfClass = rtfGroup; + info->rtfMajor = rtfEndGroup; return; } if (c != '\\') @@ -689,18 +602,18 @@ int c; */ if (c == '\t') /* ASCII 9 */ { - rtfClass = rtfControl; - rtfMajor = rtfSpecialChar; - rtfMinor = rtfTab; + info->rtfClass = rtfControl; + info->rtfMajor = rtfSpecialChar; + info->rtfMinor = rtfTab; } else { - rtfClass = rtfText; - rtfMajor = c; + info->rtfClass = rtfText; + info->rtfMajor = c; } return; } - if ((c = GetChar ()) == EOF) + if ((c = GetChar (info)) == EOF) { /* early eof, whoops (class is rtfUnknown) */ return; @@ -717,11 +630,11 @@ int c; { int c2; - if ((c = GetChar ()) != EOF && (c2 = GetChar ()) != EOF) + if ((c = GetChar (info)) != EOF && (c2 = GetChar (info)) != EOF) { /* should do isxdigit check! */ - rtfClass = rtfText; - rtfMajor = RTFCharToHex (c) * 16 + info->rtfClass = rtfText; + info->rtfMajor = RTFCharToHex (c) * 16 + RTFCharToHex (c2); return; } @@ -733,19 +646,19 @@ int c; /*if (index (":{}\\", c) != (char *) NULL)*/ /* escaped char */ if (c == ':' || c == '{' || c == '}' || c == '\\') { - rtfClass = rtfText; - rtfMajor = c; + info->rtfClass = rtfText; + info->rtfMajor = c; return; } /* control symbol */ - Lookup (rtfTextBuf); /* sets class, major, minor */ + Lookup (info, info->rtfTextBuf); /* sets class, major, minor */ return; } /* control word */ while (isalpha (c)) { - if ((c = GetChar ()) == EOF) + if ((c = GetChar (info)) == EOF) break; } @@ -758,10 +671,10 @@ int c; */ if (c != EOF) - rtfTextBuf[rtfTextLen-1] = '\0'; - Lookup (rtfTextBuf); /* sets class, major, minor */ + info->rtfTextBuf[info->rtfTextLen-1] = '\0'; + Lookup (info, info->rtfTextBuf); /* sets class, major, minor */ if (c != EOF) - rtfTextBuf[rtfTextLen-1] = c; + info->rtfTextBuf[info->rtfTextLen-1] = c; /* * Should be looking at first digit of parameter if there @@ -773,18 +686,18 @@ int c; if (c == '-') { sign = -1; - c = GetChar (); + c = GetChar (info); } if (c != EOF && isdigit (c)) { - rtfParam = 0; + info->rtfParam = 0; while (isdigit (c)) /* gobble parameter */ { - rtfParam = rtfParam * 10 + c - '0'; - if ((c = GetChar ()) == EOF) + info->rtfParam = info->rtfParam * 10 + c - '0'; + if ((c = GetChar (info)) == EOF) break; } - rtfParam *= sign; + info->rtfParam *= sign; } /* * If control symbol delimiter was a blank, gobble it. @@ -795,8 +708,8 @@ int c; if (c != EOF) { if (c != ' ') - pushedChar = c; - rtfTextBuf[--rtfTextLen] = '\0'; + info->pushedChar = c; + info->rtfTextBuf[--info->rtfTextLen] = '\0'; } } @@ -812,37 +725,37 @@ int c; */ -static int GetChar(void) +static int GetChar(RTF_Info *info) { int c; int oldBumpLine; TRACE("\n"); - if ((c = _RTFGetChar()) != EOF) + if ((c = _RTFGetChar(info)) != EOF) { - rtfTextBuf[rtfTextLen++] = c; - rtfTextBuf[rtfTextLen] = '\0'; + info->rtfTextBuf[info->rtfTextLen++] = c; + info->rtfTextBuf[info->rtfTextLen] = '\0'; } - if (prevChar == EOF) - bumpLine = 1; - oldBumpLine = bumpLine; /* non-zero if prev char was line ending */ - bumpLine = 0; + if (info->prevChar == EOF) + info->bumpLine = 1; + oldBumpLine = info->bumpLine; /* non-zero if prev char was line ending */ + info->bumpLine = 0; if (c == '\r') - bumpLine = 1; + info->bumpLine = 1; else if (c == '\n') { - bumpLine = 1; - if (prevChar == '\r') /* oops, previous \r wasn't */ + info->bumpLine = 1; + if (info->prevChar == '\r') /* oops, previous \r wasn't */ oldBumpLine = 0; /* really a line ending */ } - ++rtfLinePos; + ++info->rtfLinePos; if (oldBumpLine) /* were we supposed to increment the */ { /* line count on this char? */ - ++rtfLineNum; - rtfLinePos = 1; + ++info->rtfLineNum; + info->rtfLinePos = 1; } - prevChar = c; + info->prevChar = c; return (c); } @@ -856,19 +769,19 @@ int oldBumpLine; * part of the token text. */ -void RTFSetToken(int class, int major, int minor, int param, char *text) +void RTFSetToken(RTF_Info *info, int class, int major, int minor, int param, char *text) { TRACE("\n"); - rtfClass = class; - rtfMajor = major; - rtfMinor = minor; - rtfParam = param; + info->rtfClass = class; + info->rtfMajor = major; + info->rtfMinor = minor; + info->rtfParam = param; if (param == rtfNoParam) - (void) strcpy (rtfTextBuf, text); + (void) strcpy (info->rtfTextBuf, text); else - sprintf (rtfTextBuf, "%s%d", text, param); - rtfTextLen = strlen (rtfTextBuf); + sprintf (info->rtfTextBuf, "%s%d", text, param); + info->rtfTextLen = strlen (info->rtfTextBuf); } @@ -892,19 +805,19 @@ void RTFSetToken(int class, int major, int minor, int param, char *text) * Initialize charset stuff. */ -static void CharSetInit(void) +static void CharSetInit(RTF_Info *info) { TRACE("\n"); - autoCharSetFlags = (rtfReadCharSet | rtfSwitchCharSet); - RTFFree (genCharSetFile); - genCharSetFile = (char *) NULL; - haveGenCharSet = 0; - RTFFree (symCharSetFile); - symCharSetFile = (char *) NULL; - haveSymCharSet = 0; - curCharSet = rtfCSGeneral; - curCharCode = genCharCode; + info->autoCharSetFlags = (rtfReadCharSet | rtfSwitchCharSet); + RTFFree (info->genCharSetFile); + info->genCharSetFile = (char *) NULL; + info->haveGenCharSet = 0; + RTFFree (info->symCharSetFile); + info->symCharSetFile = (char *) NULL; + info->haveSymCharSet = 0; + info->curCharSet = rtfCSGeneral; + info->curCharCode = info->genCharCode; } @@ -913,21 +826,21 @@ static void CharSetInit(void) * done. */ -void RTFSetCharSetMap (char *name, int csId) +void RTFSetCharSetMap (RTF_Info *info, char *name, int csId) { TRACE("\n"); if ((name = RTFStrSave (name)) == (char *) NULL) /* make copy */ - RTFPanic ("RTFSetCharSetMap: out of memory"); + RTFPanic (info,"RTFSetCharSetMap: out of memory"); switch (csId) { case rtfCSGeneral: - RTFFree (genCharSetFile); /* free any previous value */ - genCharSetFile = name; + RTFFree (info->genCharSetFile); /* free any previous value */ + info->genCharSetFile = name; break; case rtfCSSymbol: - RTFFree (symCharSetFile); /* free any previous value */ - symCharSetFile = name; + RTFFree (info->symCharSetFile); /* free any previous value */ + info->symCharSetFile = name; break; } } @@ -942,24 +855,24 @@ void RTFSetCharSetMap (char *name, int csId) * */ -static void ReadCharSetMaps(void) +static void ReadCharSetMaps(RTF_Info *info) { char buf[rtfBufSiz]; TRACE("\n"); - if (genCharSetFile != (char *) NULL) - (void) strcpy (buf, genCharSetFile); + if (info->genCharSetFile != (char *) NULL) + (void) strcpy (buf, info->genCharSetFile); else - sprintf (buf, "%s-gen", &rtfTextBuf[1]); - if (RTFReadCharSetMap (rtfCSGeneral) == 0) - RTFPanic ("ReadCharSetMaps: Cannot read charset map %s", buf); - if (symCharSetFile != (char *) NULL) - (void) strcpy (buf, symCharSetFile); + sprintf (buf, "%s-gen", &info->rtfTextBuf[1]); + if (RTFReadCharSetMap (info, rtfCSGeneral) == 0) + RTFPanic (info,"ReadCharSetMaps: Cannot read charset map %s", buf); + if (info->symCharSetFile != (char *) NULL) + (void) strcpy (buf, info->symCharSetFile); else - sprintf (buf, "%s-sym", &rtfTextBuf[1]); - if (RTFReadCharSetMap (rtfCSSymbol) == 0) - RTFPanic ("ReadCharSetMaps: Cannot read charset map %s", buf); + sprintf (buf, "%s-sym", &info->rtfTextBuf[1]); + if (RTFReadCharSetMap (info, rtfCSSymbol) == 0) + RTFPanic (info,"ReadCharSetMaps: Cannot read charset map %s", buf); } @@ -969,7 +882,7 @@ char buf[rtfBufSiz]; * this form : array[caracter_ident] = caracter; */ -int RTFReadCharSetMap(int csId) +int RTFReadCharSetMap(RTF_Info *info, int csId) { int *stdCodeArray; int i; @@ -982,8 +895,8 @@ int RTFReadCharSetMap(int csId) return (0); /* illegal charset id */ case rtfCSGeneral: - haveGenCharSet = 1; - stdCodeArray = genCharCode; + info->haveGenCharSet = 1; + stdCodeArray = info->genCharCode; for (i = 0; i < charSetSize; i++) { stdCodeArray[i] = rtfSC_nothing; @@ -997,8 +910,8 @@ int RTFReadCharSetMap(int csId) case rtfCSSymbol: - haveSymCharSet = 1; - stdCodeArray = symCharCode; + info->haveSymCharSet = 1; + stdCodeArray = info->symCharCode; for (i = 0; i < charSetSize; i++) { stdCodeArray[i] = rtfSC_nothing; @@ -1020,7 +933,7 @@ int RTFReadCharSetMap(int csId) * Return -1 if name is unknown. */ -int RTFStdCharCode(char *name) +int RTFStdCharCode(RTF_Info *info, char *name) { int i; @@ -1040,7 +953,7 @@ int i; * Return NULL if code is unknown. */ -char *RTFStdCharName(int code) +char *RTFStdCharName(RTF_Info *info, int code) { if (code < 0 || code >= rtfSC_MaxChar) return ((char *) NULL); @@ -1057,30 +970,30 @@ char *RTFStdCharName(int code) * and reads the map as necessary. */ -int RTFMapChar(int c) +int RTFMapChar(RTF_Info *info, int c) { TRACE("\n"); - switch (curCharSet) + switch (info->curCharSet) { case rtfCSGeneral: - if (!haveGenCharSet) + if (!info->haveGenCharSet) { - if (RTFReadCharSetMap (rtfCSGeneral) == 0) - RTFPanic ("RTFMapChar: cannot read ansi-gen"); + if (RTFReadCharSetMap (info, rtfCSGeneral) == 0) + RTFPanic (info,"RTFMapChar: cannot read ansi-gen"); } break; case rtfCSSymbol: - if (!haveSymCharSet) + if (!info->haveSymCharSet) { - if (RTFReadCharSetMap (rtfCSSymbol) == 0) - RTFPanic ("RTFMapChar: cannot read ansi-sym"); + if (RTFReadCharSetMap (info, rtfCSSymbol) == 0) + RTFPanic (info,"RTFMapChar: cannot read ansi-sym"); } break; } if (c < 0 || c >= charSetSize) return (rtfSC_nothing); - return (curCharCode[c]); + return (info->curCharCode[c]); } @@ -1088,7 +1001,7 @@ int RTFMapChar(int c) * Set the current character set. If csId is illegal, uses general charset. */ -void RTFSetCharSet(int csId) +void RTFSetCharSet(RTF_Info *info, int csId) { TRACE("\n"); @@ -1096,20 +1009,20 @@ void RTFSetCharSet(int csId) { default: /* use general if csId unknown */ case rtfCSGeneral: - curCharCode = genCharCode; - curCharSet = csId; + info->curCharCode = info->genCharCode; + info->curCharSet = csId; break; case rtfCSSymbol: - curCharCode = symCharCode; - curCharSet = csId; + info->curCharCode = info->symCharCode; + info->curCharSet = csId; break; } } -int RTFGetCharSet(void) +int RTFGetCharSet(RTF_Info *info) { - return (curCharSet); + return (info->curCharSet); } @@ -1141,7 +1054,7 @@ int RTFGetCharSet(void) * braces around each table entry; try to adjust for that. */ -static void ReadFontTbl(void) +static void ReadFontTbl(RTF_Info *info) { RTFFont *fp = NULL; char buf[rtfBufSiz], *bp; @@ -1152,29 +1065,29 @@ char *fn = "ReadFontTbl"; for (;;) { - (void) RTFGetToken (); - if (RTFCheckCM (rtfGroup, rtfEndGroup)) + (void) RTFGetToken (info); + if (RTFCheckCM (info, rtfGroup, rtfEndGroup)) break; if (old < 0) /* first entry - determine tbl type */ { - if (RTFCheckCMM (rtfControl, rtfCharAttr, rtfFontNum)) + if (RTFCheckCMM (info, rtfControl, rtfCharAttr, rtfFontNum)) old = 1; /* no brace */ - else if (RTFCheckCM (rtfGroup, rtfBeginGroup)) + else if (RTFCheckCM (info, rtfGroup, rtfBeginGroup)) old = 0; /* brace */ else /* can't tell! */ - RTFPanic ("%s: Cannot determine format", fn); + RTFPanic (info, "%s: Cannot determine format", fn); } if (old == 0) /* need to find "{" here */ { - if (!RTFCheckCM (rtfGroup, rtfBeginGroup)) - RTFPanic ("%s: missing \"{\"", fn); - (void) RTFGetToken (); /* yes, skip to next token */ + if (!RTFCheckCM (info, rtfGroup, rtfBeginGroup)) + RTFPanic (info, "%s: missing \"{\"", fn); + (void) RTFGetToken (info); /* yes, skip to next token */ } if ((fp = New (RTFFont)) == (RTFFont *) NULL) - RTFPanic ("%s: cannot allocate font entry", fn); + RTFPanic (info, "%s: cannot allocate font entry", fn); - fp->rtfNextFont = fontList; - fontList = fp; + fp->rtfNextFont = info->fontList; + info->fontList = fp; fp->rtfFName = (char *) NULL; fp->rtfFAltName = (char *) NULL; @@ -1185,77 +1098,77 @@ char *fn = "ReadFontTbl"; fp->rtfFType = 0; fp->rtfFCodePage = 0; - while (rtfClass != rtfEOF - && !RTFCheckCM (rtfText, ';') - && !RTFCheckCM (rtfGroup, rtfEndGroup)) + while (info->rtfClass != rtfEOF + && !RTFCheckCM (info, rtfText, ';') + && !RTFCheckCM (info, rtfGroup, rtfEndGroup)) { - if (rtfClass == rtfControl) + if (info->rtfClass == rtfControl) { - switch (rtfMajor) + switch (info->rtfMajor) { default: /* ignore token but announce it */ - RTFMsg ("%s: unknown token \"%s\"\n", - fn, rtfTextBuf); + RTFMsg (info,"%s: unknown token \"%s\"\n", + fn, info->rtfTextBuf); + break; case rtfFontFamily: - fp->rtfFFamily = rtfMinor; + fp->rtfFFamily = info->rtfMinor; break; case rtfCharAttr: - switch (rtfMinor) + switch (info->rtfMinor) { default: break; /* ignore unknown? */ case rtfFontNum: - fp->rtfFNum = rtfParam; + fp->rtfFNum = info->rtfParam; break; } break; case rtfFontAttr: - switch (rtfMinor) + switch (info->rtfMinor) { default: break; /* ignore unknown? */ case rtfFontCharSet: - fp->rtfFCharSet = rtfParam; + fp->rtfFCharSet = info->rtfParam; break; case rtfFontPitch: - fp->rtfFPitch = rtfParam; + fp->rtfFPitch = info->rtfParam; break; case rtfFontCodePage: - fp->rtfFCodePage = rtfParam; + fp->rtfFCodePage = info->rtfParam; break; case rtfFTypeNil: case rtfFTypeTrueType: - fp->rtfFType = rtfParam; + fp->rtfFType = info->rtfParam; break; } break; } } - else if (RTFCheckCM (rtfGroup, rtfBeginGroup)) /* dest */ + else if (RTFCheckCM (info, rtfGroup, rtfBeginGroup)) /* dest */ { - RTFSkipGroup (); /* ignore for now */ + RTFSkipGroup (info); /* ignore for now */ } - else if (rtfClass == rtfText) /* font name */ + else if (info->rtfClass == rtfText) /* font name */ { bp = buf; - while (rtfClass != rtfEOF - && !RTFCheckCM (rtfText, ';') - && !RTFCheckCM (rtfGroup, rtfEndGroup)) + while (info->rtfClass == rtfText + && !RTFCheckCM (info, rtfText, ';')) { - *bp++ = rtfMajor; - (void) RTFGetToken (); + *bp++ = info->rtfMajor; + (void) RTFGetToken (info); } /* FIX: in some cases the isn't finished with a semi-column */ - if(RTFCheckCM (rtfGroup, rtfEndGroup)) + if(RTFCheckCM (info, rtfGroup, rtfEndGroup)) { - RTFUngetToken (); + RTFUngetToken (info); } *bp = '\0'; fp->rtfFName = RTFStrSave (buf); if (fp->rtfFName == (char *) NULL) - RTFPanic ("%s: cannot allocate font name", fn); + RTFPanic (info, "%s: cannot allocate font name", fn); /* already have next token; don't read one */ /* at bottom of loop */ continue; @@ -1263,24 +1176,24 @@ char *fn = "ReadFontTbl"; else { /* ignore token but announce it */ - RTFMsg ("%s: unknown token \"%s\"\n", - fn, rtfTextBuf); + RTFMsg (info, "%s: unknown token \"%s\"\n", + fn,info->rtfTextBuf); } - (void) RTFGetToken (); + (void) RTFGetToken (info); } if (old == 0) /* need to see "}" here */ { - (void) RTFGetToken (); - if (!RTFCheckCM (rtfGroup, rtfEndGroup)) - RTFPanic ("%s: missing \"}\"", fn); + (void) RTFGetToken (info); + if (!RTFCheckCM (info, rtfGroup, rtfEndGroup)) + RTFPanic (info, "%s: missing \"}\"", fn); } } if (fp->rtfFNum == -1) - RTFPanic ("%s: missing font number", fn); + RTFPanic (info,"%s: missing font number", fn); /* * Could check other pieces of structure here, too, I suppose. */ - RTFRouteToken (); /* feed "}" back to router */ + RTFRouteToken (info); /* feed "}" back to router */ } @@ -1293,7 +1206,7 @@ char *fn = "ReadFontTbl"; * here. */ -static void ReadColorTbl(void) +static void ReadColorTbl(RTF_Info *info) { RTFColor *cp; int cnum = 0; @@ -1303,29 +1216,29 @@ char *fn = "ReadColorTbl"; for (;;) { - (void) RTFGetToken (); - if (RTFCheckCM (rtfGroup, rtfEndGroup)) + (void) RTFGetToken (info); + if (RTFCheckCM (info, rtfGroup, rtfEndGroup)) break; if ((cp = New (RTFColor)) == (RTFColor *) NULL) - RTFPanic ("%s: cannot allocate color entry", fn); + RTFPanic (info,"%s: cannot allocate color entry", fn); cp->rtfCNum = cnum++; cp->rtfCRed = cp->rtfCGreen = cp->rtfCBlue = -1; - cp->rtfNextColor = colorList; - colorList = cp; - while (RTFCheckCM (rtfControl, rtfColorName)) + cp->rtfNextColor = info->colorList; + info->colorList = cp; + while (RTFCheckCM (info, rtfControl, rtfColorName)) { - switch (rtfMinor) + switch (info->rtfMinor) { - case rtfRed: cp->rtfCRed = rtfParam; break; - case rtfGreen: cp->rtfCGreen = rtfParam; break; - case rtfBlue: cp->rtfCBlue = rtfParam; break; + case rtfRed: cp->rtfCRed = info->rtfParam; break; + case rtfGreen: cp->rtfCGreen = info->rtfParam; break; + case rtfBlue: cp->rtfCBlue = info->rtfParam; break; } - RTFGetToken (); + RTFGetToken (info); } - if (!RTFCheckCM (rtfText, (int) ';')) - RTFPanic ("%s: malformed entry", fn); + if (!RTFCheckCM (info, rtfText, (int) ';')) + RTFPanic (info,"%s: malformed entry", fn); } - RTFRouteToken (); /* feed "}" back to router */ + RTFRouteToken (info); /* feed "}" back to router */ } @@ -1334,7 +1247,7 @@ char *fn = "ReadColorTbl"; * all others do. Normal style is given style rtfNormalStyleNum. */ -static void ReadStyleSheet(void) +static void ReadStyleSheet(RTF_Info *info) { RTFStyle *sp; RTFStyleElt *sep, *sepLast; @@ -1345,11 +1258,11 @@ char *fn = "ReadStyleSheet"; for (;;) { - (void) RTFGetToken (); - if (RTFCheckCM (rtfGroup, rtfEndGroup)) + (void) RTFGetToken (info); + if (RTFCheckCM (info, rtfGroup, rtfEndGroup)) break; if ((sp = New (RTFStyle)) == (RTFStyle *) NULL) - RTFPanic ("%s: cannot allocate stylesheet entry", fn); + RTFPanic (info,"%s: cannot allocate stylesheet entry", fn); sp->rtfSName = (char *) NULL; sp->rtfSNum = -1; sp->rtfSType = rtfParStyle; @@ -1357,63 +1270,63 @@ char *fn = "ReadStyleSheet"; sp->rtfSBasedOn = rtfNoStyleNum; sp->rtfSNextPar = -1; sp->rtfSSEList = sepLast = (RTFStyleElt *) NULL; - sp->rtfNextStyle = styleList; + sp->rtfNextStyle = info->styleList; sp->rtfExpanding = 0; - styleList = sp; - if (!RTFCheckCM (rtfGroup, rtfBeginGroup)) - RTFPanic ("%s: missing \"{\"", fn); + info->styleList = sp; + if (!RTFCheckCM (info, rtfGroup, rtfBeginGroup)) + RTFPanic (info,"%s: missing \"{\"", fn); for (;;) { - (void) RTFGetToken (); - if (rtfClass == rtfEOF - || RTFCheckCM (rtfText, ';')) + (void) RTFGetToken (info); + if (info->rtfClass == rtfEOF + || RTFCheckCM (info, rtfText, ';')) break; - if (rtfClass == rtfControl) + if (info->rtfClass == rtfControl) { - if (RTFCheckMM (rtfSpecialChar, rtfOptDest)) + if (RTFCheckMM (info, rtfSpecialChar, rtfOptDest)) continue; /* ignore "\*" */ - if (RTFCheckMM (rtfParAttr, rtfStyleNum)) + if (RTFCheckMM (info, rtfParAttr, rtfStyleNum)) { - sp->rtfSNum = rtfParam; + sp->rtfSNum = info->rtfParam; sp->rtfSType = rtfParStyle; continue; } - if (RTFCheckMM (rtfCharAttr, rtfCharStyleNum)) + if (RTFCheckMM (info, rtfCharAttr, rtfCharStyleNum)) { - sp->rtfSNum = rtfParam; + sp->rtfSNum = info->rtfParam; sp->rtfSType = rtfCharStyle; continue; } - if (RTFCheckMM (rtfSectAttr, rtfSectStyleNum)) + if (RTFCheckMM (info, rtfSectAttr, rtfSectStyleNum)) { - sp->rtfSNum = rtfParam; + sp->rtfSNum = info->rtfParam; sp->rtfSType = rtfSectStyle; continue; } - if (RTFCheckMM (rtfStyleAttr, rtfBasedOn)) + if (RTFCheckMM (info, rtfStyleAttr, rtfBasedOn)) { - sp->rtfSBasedOn = rtfParam; + sp->rtfSBasedOn = info->rtfParam; continue; } - if (RTFCheckMM (rtfStyleAttr, rtfAdditive)) + if (RTFCheckMM (info, rtfStyleAttr, rtfAdditive)) { sp->rtfSAdditive = 1; continue; } - if (RTFCheckMM (rtfStyleAttr, rtfNext)) + if (RTFCheckMM (info, rtfStyleAttr, rtfNext)) { - sp->rtfSNextPar = rtfParam; + sp->rtfSNextPar = info->rtfParam; continue; } if ((sep = New (RTFStyleElt)) == (RTFStyleElt *) NULL) - RTFPanic ("%s: cannot allocate style element", fn); - sep->rtfSEClass = rtfClass; - sep->rtfSEMajor = rtfMajor; - sep->rtfSEMinor = rtfMinor; - sep->rtfSEParam = rtfParam; - if ((sep->rtfSEText = RTFStrSave (rtfTextBuf)) + RTFPanic (info,"%s: cannot allocate style element", fn); + sep->rtfSEClass = info->rtfClass; + sep->rtfSEMajor = info->rtfMajor; + sep->rtfSEMinor = info->rtfMinor; + sep->rtfSEParam = info->rtfParam; + if ((sep->rtfSEText = RTFStrSave (info->rtfTextBuf)) == (char *) NULL) - RTFPanic ("%s: cannot allocate style element text", fn); + RTFPanic (info,"%s: cannot allocate style element text", fn); if (sepLast == (RTFStyleElt *) NULL) sp->rtfSSEList = sep; /* first element */ else /* add to end */ @@ -1421,43 +1334,43 @@ char *fn = "ReadStyleSheet"; sep->rtfNextSE = (RTFStyleElt *) NULL; sepLast = sep; } - else if (RTFCheckCM (rtfGroup, rtfBeginGroup)) + else if (RTFCheckCM (info, rtfGroup, rtfBeginGroup)) { /* * This passes over "{\*\keycode ... }, among * other things. A temporary (perhaps) hack. */ - RTFSkipGroup (); + RTFSkipGroup (info); continue; } - else if (rtfClass == rtfText) /* style name */ + else if (info->rtfClass == rtfText) /* style name */ { bp = buf; - while (rtfClass == rtfText) + while (info->rtfClass == rtfText) { - if (rtfMajor == ';') + if (info->rtfMajor == ';') { /* put back for "for" loop */ - (void) RTFUngetToken (); + (void) RTFUngetToken (info); break; } - *bp++ = rtfMajor; - (void) RTFGetToken (); + *bp++ = info->rtfMajor; + (void) RTFGetToken (info); } *bp = '\0'; if ((sp->rtfSName = RTFStrSave (buf)) == (char *) NULL) - RTFPanic ("%s: cannot allocate style name", fn); + RTFPanic (info, "%s: cannot allocate style name", fn); } else /* unrecognized */ { /* ignore token but announce it */ - RTFMsg ("%s: unknown token \"%s\"\n", - fn, rtfTextBuf); + RTFMsg (info, "%s: unknown token \"%s\"\n", + fn, info->rtfTextBuf); } } - (void) RTFGetToken (); - if (!RTFCheckCM (rtfGroup, rtfEndGroup)) - RTFPanic ("%s: missing \"}\"", fn); + (void) RTFGetToken (info); + if (!RTFCheckCM (info, rtfGroup, rtfEndGroup)) + RTFPanic (info, "%s: missing \"}\"", fn); /* * Check over the style structure. A name is a must. @@ -1470,39 +1383,39 @@ char *fn = "ReadStyleSheet"; * Some German RTF writers use "Standard" instead of "Normal". */ if (sp->rtfSName == (char *) NULL) - RTFPanic ("%s: missing style name", fn); + RTFPanic (info,"%s: missing style name", fn); if (sp->rtfSNum < 0) { if (strncmp (buf, "Normal", 6) != 0 && strncmp (buf, "Standard", 8) != 0) - RTFPanic ("%s: missing style number", fn); + RTFPanic (info,"%s: missing style number", fn); sp->rtfSNum = rtfNormalStyleNum; } if (sp->rtfSNextPar == -1) /* if \snext not given, */ sp->rtfSNextPar = sp->rtfSNum; /* next is itself */ } - RTFRouteToken (); /* feed "}" back to router */ + RTFRouteToken (info); /* feed "}" back to router */ } -static void ReadInfoGroup(void) +static void ReadInfoGroup(RTF_Info *info) { - RTFSkipGroup (); - RTFRouteToken (); /* feed "}" back to router */ + RTFSkipGroup (info); + RTFRouteToken (info); /* feed "}" back to router */ } -static void ReadPictGroup(void) +static void ReadPictGroup(RTF_Info *info) { - RTFSkipGroup (); - RTFRouteToken (); /* feed "}" back to router */ + RTFSkipGroup (info); + RTFRouteToken (info); /* feed "}" back to router */ } -static void ReadObjGroup(void) +static void ReadObjGroup(RTF_Info *info) { - RTFSkipGroup (); - RTFRouteToken (); /* feed "}" back to router */ + RTFSkipGroup (info); + RTFRouteToken (info); /* feed "}" back to router */ } @@ -1514,13 +1427,13 @@ static void ReadObjGroup(void) */ -RTFStyle *RTFGetStyle(int num) +RTFStyle *RTFGetStyle(RTF_Info *info, int num) { RTFStyle *s; if (num == -1) - return (styleList); - for (s = styleList; s != (RTFStyle *) NULL; s = s->rtfNextStyle) + return (info->styleList); + for (s = info->styleList; s != (RTFStyle *) NULL; s = s->rtfNextStyle) { if (s->rtfSNum == num) break; @@ -1529,13 +1442,13 @@ RTFStyle *s; } -RTFFont *RTFGetFont(int num) +RTFFont *RTFGetFont(RTF_Info *info, int num) { RTFFont *f; if (num == -1) - return (fontList); - for (f = fontList; f != (RTFFont *) NULL; f = f->rtfNextFont) + return (info->fontList); + for (f = info->fontList; f != (RTFFont *) NULL; f = f->rtfNextFont) { if (f->rtfFNum == num) break; @@ -1544,13 +1457,13 @@ RTFFont *f; } -RTFColor *RTFGetColor(int num) +RTFColor *RTFGetColor(RTF_Info *info, int num) { RTFColor *c; if (num == -1) - return (colorList); - for (c = colorList; c != (RTFColor *) NULL; c = c->rtfNextColor) + return (info->colorList); + for (c = info->colorList; c != (RTFColor *) NULL; c = c->rtfNextColor) { if (c->rtfCNum == num) break; @@ -1566,17 +1479,17 @@ RTFColor *c; * Expand style n, if there is such a style. */ -void RTFExpandStyle(int n) +void RTFExpandStyle(RTF_Info *info, int n) { RTFStyle *s; RTFStyleElt *se; TRACE("\n"); - if (n == -1 || (s = RTFGetStyle (n)) == (RTFStyle *) NULL) + if (n == -1 || (s = RTFGetStyle (info, n)) == (RTFStyle *) NULL) return; if (s->rtfExpanding != 0) - RTFPanic ("Style expansion loop, style %d", n); + RTFPanic (info,"Style expansion loop, style %d", n); s->rtfExpanding = 1; /* set expansion flag for loop detection */ /* * Expand "based-on" style (unless it's the same as the current @@ -1588,9 +1501,9 @@ RTFStyleElt *se; */ if (n != s->rtfSBasedOn) { - RTFSetToken (rtfControl, rtfParAttr, rtfStyleNum, + RTFSetToken (info, rtfControl, rtfParAttr, rtfStyleNum, s->rtfSBasedOn, "\\s"); - RTFRouteToken (); + RTFRouteToken (info); } /* * Now route the tokens unique to this style. RTFSetToken() @@ -1599,13 +1512,13 @@ RTFStyleElt *se; */ for (se = s->rtfSSEList; se != (RTFStyleElt *) NULL; se = se->rtfNextSE) { - rtfClass = se->rtfSEClass; - rtfMajor = se->rtfSEMajor; - rtfMinor = se->rtfSEMinor; - rtfParam = se->rtfSEParam; - (void) strcpy (rtfTextBuf, se->rtfSEText); - rtfTextLen = strlen (rtfTextBuf); - RTFRouteToken (); + info->rtfClass = se->rtfSEClass; + info->rtfMajor = se->rtfSEMajor; + info->rtfMinor = se->rtfSEMinor; + info->rtfParam = se->rtfSEParam; + (void) strcpy (info->rtfTextBuf, se->rtfSEText); + info->rtfTextLen = strlen (info->rtfTextBuf); + RTFRouteToken (info); } s->rtfExpanding = 0; /* done - clear expansion flag */ } @@ -2529,7 +2442,7 @@ static RTFKey rtfKey[] = * Initialize lookup table hash values. Only need to do this once. */ -static void LookupInit(void) +static void LookupInit() { static int inited = 0; RTFKey *rp; @@ -2548,7 +2461,7 @@ RTFKey *rp; * not found, the class turns into rtfUnknown. */ -static void Lookup(char *s) +static void Lookup(RTF_Info *info, char *s) { RTFKey *rp; int hash; @@ -2560,13 +2473,13 @@ int hash; { if (hash == rp->rtfKHash && strcmp (s, rp->rtfKStr) == 0) { - rtfClass = rtfControl; - rtfMajor = rp->rtfKMajor; - rtfMinor = rp->rtfKMinor; + info->rtfClass = rtfControl; + info->rtfMajor = rp->rtfKMajor; + info->rtfMinor = rp->rtfKMinor; return; } } - rtfClass = rtfUnknown; + info->rtfClass = rtfUnknown; } @@ -2636,21 +2549,21 @@ void RTFFree(char *p) * Token comparison routines */ -int RTFCheckCM(int class, int major) +int RTFCheckCM(RTF_Info *info, int class, int major) { - return (rtfClass == class && rtfMajor == major); + return (info->rtfClass == class && info->rtfMajor == major); } -int RTFCheckCMM(int class, int major, int minor) +int RTFCheckCMM(RTF_Info *info, int class, int major, int minor) { - return (rtfClass == class && rtfMajor == major && rtfMinor == minor); + return (info->rtfClass == class && info->rtfMajor == major && info->rtfMinor == minor); } -int RTFCheckMM(int major, int minor) +int RTFCheckMM(RTF_Info *info, int major, int minor) { - return (rtfMajor == major && rtfMinor == minor); + return (info->rtfMajor == major && info->rtfMinor == minor); } @@ -2696,7 +2609,7 @@ int RTFHexToChar(int i) * */ -int RTFReadOutputMap(char *outMap[], int reinit) +int RTFReadOutputMap(RTF_Info *info, char *outMap[], int reinit) { int i; int stdCode; @@ -2714,7 +2627,7 @@ int RTFReadOutputMap(char *outMap[], int reinit) { name = text_map[i]; seq = text_map[i+1]; - stdCode = RTFStdCharCode( name ); + stdCode = RTFStdCharCode( info, name ); outMap[stdCode] = seq; } @@ -2728,21 +2641,17 @@ int RTFReadOutputMap(char *outMap[], int reinit) */ -static FILE *(*libFileOpen) () = NULL; - - - -void RTFSetOpenLibFileProc(FILE *(*proc)()) +void RTFSetOpenLibFileProc(RTF_Info *info, FILE *(*proc)()) { - libFileOpen = proc; + info->libFileOpen = proc; } -FILE *RTFOpenLibFile (char *file, char *mode) +FILE *RTFOpenLibFile (RTF_Info *info, char *file, char *mode) { - if (libFileOpen == NULL) + if (info->libFileOpen == NULL) return ((FILE *) NULL); - return ((*libFileOpen) (file, mode)); + return ((*info->libFileOpen) (file, mode)); } @@ -2759,22 +2668,7 @@ FILE *RTFOpenLibFile (char *file, char *mode) */ -static void DefaultMsgProc(char *s) -{ - MESSAGE( "%s", s); -} - - -static RTFFuncPtr msgProc = DefaultMsgProc; - - -void RTFSetMsgProc(RTFFuncPtr proc) -{ - msgProc = proc; -} - - -void RTFMsg (char *fmt, ...) +void RTFMsg (RTF_Info *info, char *fmt, ...) { char buf[rtfBufSiz]; @@ -2782,7 +2676,7 @@ char buf[rtfBufSiz]; va_start (args,fmt); vsprintf (buf, fmt, args); va_end (args); - (*msgProc) (buf); + MESSAGE( "%s", buf); } @@ -2796,23 +2690,15 @@ char buf[rtfBufSiz]; * has been read if prevChar is EOF). */ -static void DefaultPanicProc(char *s) +static void DefaultPanicProc(RTF_Info *info, char *s) { MESSAGE( "%s", s); /*exit (1);*/ } -static RTFFuncPtr panicProc = DefaultPanicProc; - -void RTFSetPanicProc(RTFFuncPtr proc) -{ - panicProc = proc; -} - - -void RTFPanic(char *fmt, ...) +void RTFPanic(RTF_Info *info, char *fmt, ...) { char buf[rtfBufSiz]; @@ -2821,11 +2707,11 @@ char buf[rtfBufSiz]; vsprintf (buf, fmt, args); va_end (args); (void) strcat (buf, "\n"); - if (prevChar != EOF && rtfTextBuf != (char *) NULL) + if (info->prevChar != EOF && info->rtfTextBuf != (char *) NULL) { sprintf (buf + strlen (buf), "Last token read was \"%s\" near line %ld, position %d.\n", - rtfTextBuf, rtfLineNum, rtfLinePos); + info->rtfTextBuf, info->rtfLineNum, info->rtfLinePos); } - (*panicProc) (buf); + DefaultPanicProc(info, buf); } diff --git a/reactos/lib/richedit/riched32.def b/reactos/lib/richedit/riched32.def deleted file mode 100644 index d36f75dc7f3..00000000000 --- a/reactos/lib/richedit/riched32.def +++ /dev/null @@ -1,6 +0,0 @@ -; File generated automatically from richedit/riched32.spec; do not edit! - -LIBRARY riched32.dll - -EXPORTS - DllGetVersion@4=RICHED32_DllGetVersion@4 @2 diff --git a/reactos/lib/richedit/riched32.edf b/reactos/lib/richedit/riched32.edf deleted file mode 100644 index fdbe59376c1..00000000000 --- a/reactos/lib/richedit/riched32.edf +++ /dev/null @@ -1,4 +0,0 @@ -LIBRARY riched32.dll - -EXPORTS - DllGetVersion=RICHED32_DllGetVersion@4 @2 diff --git a/reactos/lib/richedit/riched32.rc b/reactos/lib/richedit/riched32.rc deleted file mode 100644 index 7823ba80522..00000000000 --- a/reactos/lib/richedit/riched32.rc +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include - -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US - -VS_VERSION_INFO VERSIONINFO - FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD - PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", RES_STR_COMPANY_NAME - VALUE "FileDescription", "Rich Text Edit Control\0" - VALUE "FileVersion", RES_STR_FILE_VERSION - VALUE "InternalName", "riched32\0" - VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT - VALUE "OriginalFilename", "riched32.dll\0" - VALUE "ProductName", RES_STR_PRODUCT_NAME - VALUE "ProductVersion", RES_STR_PRODUCT_VERSION - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - diff --git a/reactos/lib/richedit/riched32.spec b/reactos/lib/richedit/riched32.spec new file mode 100644 index 00000000000..1f7dffe9b97 --- /dev/null +++ b/reactos/lib/richedit/riched32.spec @@ -0,0 +1 @@ +2 stdcall DllGetVersion (ptr) RICHED32_DllGetVersion diff --git a/reactos/lib/richedit/richedit.c b/reactos/lib/richedit/richedit.c index 3cf8edc5f85..d35d5e9c982 100644 --- a/reactos/lib/richedit/richedit.c +++ b/reactos/lib/richedit/richedit.c @@ -52,6 +52,7 @@ HANDLE RICHED32_hHeap = NULL; , \ hwnd, (UINT)wParam, (UINT)lParam) +LPVOID* WINAPI CreateIRichEditOle(); /*********************************************************************** * DllMain [Internal] Initializes the internal 'RICHED32.DLL'. @@ -94,6 +95,16 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) INT RICHEDIT_GetSelText(HWND hwnd,LPSTR lpstrBuffer); +const WCHAR RichEditInfoStr[] = { '_','R','T','F','_','I','n','f','o', 0 }; + +typedef struct _RTFControl_info +{ + HWND hwndEdit; + HWND hwndParent; + char* rtfBuffer; + RTF_Info *parser; +} RTFControl_Info; + /* * * DESCRIPTION: @@ -103,19 +114,15 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - int RTFToBuffer(char* pBuffer, int nBufferSize); + int RTFToBuffer(RTF_Info *parser, char* pBuffer, int nBufferSize); LONG newstyle = 0; LONG style = 0; - - static HWND hwndEdit; - static HWND hwndParent; - static char* rtfBuffer; + RTFControl_Info *info; int rtfBufferSize; - CHARRANGE *cr; - TRACE("previous hwndEdit: %p hwndParent %p\n",hwndEdit,hwndParent); - hwndEdit = GetWindow(hwnd,GW_CHILD); - TRACE("uMsg: 0x%x hwnd: %p hwndEdit: %p\n",uMsg,hwnd,hwndEdit); + + info = GetPropW( hwnd, RichEditInfoStr ); + TRACE("uMsg: 0x%x hwnd: %p\n",uMsg,hwnd); switch (uMsg) { @@ -128,8 +135,14 @@ static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, case WM_NCCREATE : TRACE_EDIT_MSG32("WM_NCCREATE"); + info = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof (RTFControl_Info)); + info->parser = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof (RTF_Info)); + SetPropW(hwnd, RichEditInfoStr, (HANDLE)info); + /* remove SCROLLBARS from the current window style */ - hwndParent = ((LPCREATESTRUCTA) lParam)->hwndParent; + info->hwndParent = ((LPCREATESTRUCTA) lParam)->hwndParent; newstyle = style = ((LPCREATESTRUCTA) lParam)->style; newstyle &= ~WS_HSCROLL; @@ -138,26 +151,26 @@ static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, newstyle &= ~ES_AUTOVSCROLL; SetWindowLongA(hwnd,GWL_STYLE, newstyle); - TRACE("previous hwndEdit: %p\n",hwndEdit); - hwndEdit = CreateWindowA ("edit", ((LPCREATESTRUCTA) lParam)->lpszName, + TRACE("previous hwndEdit: %p\n",info->hwndEdit); + info->hwndEdit = CreateWindowA ("edit", ((LPCREATESTRUCTA) lParam)->lpszName, style, 0, 0, 0, 0, hwnd, (HMENU) ID_EDIT, ((LPCREATESTRUCTA) lParam)->hInstance, NULL) ; - TRACE("hwndEdit: %p hwnd: %p\n",hwndEdit,hwnd); + TRACE("hwndEdit: %p hwnd: %p\n",info->hwndEdit,hwnd); - if (hwndEdit) + if (info->hwndEdit) return TRUE ; else return FALSE ; case WM_SETFOCUS : TRACE_EDIT_MSG32("WM_SETFOCUS"); - SetFocus (hwndEdit) ; + SetFocus (info->hwndEdit) ; return 0 ; case WM_SIZE : TRACE_EDIT_MSG32("WM_SIZE"); - MoveWindow (hwndEdit, 0, 0, LOWORD (lParam), HIWORD (lParam), TRUE) ; + MoveWindow (info->hwndEdit, 0, 0, LOWORD (lParam), HIWORD (lParam), TRUE) ; return 0 ; case WM_COMMAND : @@ -169,7 +182,7 @@ static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, case EN_SETFOCUS: case EN_UPDATE: case EN_VSCROLL: - return SendMessageA(hwndParent, WM_COMMAND, + return SendMessageA(info->hwndParent, WM_COMMAND, wParam, (LPARAM)(hwnd)); case EN_ERRSPACE: @@ -183,22 +196,22 @@ static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, TRACE_EDIT_MSG32("EM_STREAMIN"); /* setup the RTF parser */ - RTFSetEditStream(( EDITSTREAM*)lParam); - rtfFormat = wParam&(SF_TEXT|SF_RTF); - WriterInit(); - RTFInit (); - BeginFile(); + RTFSetEditStream(info->parser,( EDITSTREAM*)lParam); + info->parser->rtfFormat = wParam&(SF_TEXT|SF_RTF); + WriterInit(info->parser); + RTFInit (info->parser); + BeginFile(info->parser); /* do the parsing */ - RTFRead (); + RTFRead (info->parser); - rtfBufferSize = RTFToBuffer(NULL, 0); - rtfBuffer = HeapAlloc(RICHED32_hHeap, 0,rtfBufferSize*sizeof(char)); - if(rtfBuffer) + rtfBufferSize = RTFToBuffer(info->parser,NULL, 0); + info->rtfBuffer = HeapAlloc(RICHED32_hHeap, 0,rtfBufferSize*sizeof(char)); + if(info->rtfBuffer) { - RTFToBuffer(rtfBuffer, rtfBufferSize); - SetWindowTextA(hwndEdit,rtfBuffer); - HeapFree(RICHED32_hHeap, 0,rtfBuffer); + RTFToBuffer(info->parser,info->rtfBuffer, rtfBufferSize); + SetWindowTextA(info->hwndEdit,info->rtfBuffer); + HeapFree(RICHED32_hHeap, 0,info->rtfBuffer); } else WARN("Not enough memory for a allocating rtfBuffer\n"); @@ -226,7 +239,7 @@ static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, case EM_EXGETSEL: TRACE_EDIT_MSG32("EM_EXGETSEL -> EM_GETSEL"); cr = (VOID *) lParam; - if (hwndEdit) SendMessageA( hwndEdit, EM_GETSEL, (INT)&cr->cpMin, (INT)&cr->cpMax); + if (info->hwndEdit) SendMessageA( info->hwndEdit, EM_GETSEL, (INT)&cr->cpMin, (INT)&cr->cpMax); TRACE("cpMin: 0x%x cpMax: 0x%x\n",(INT)cr->cpMin,(INT)cr->cpMax); return 0; @@ -238,18 +251,18 @@ static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, { limit = 0xFFFFFFFF; } - return SendMessageA(hwndEdit,EM_SETLIMITTEXT,limit,0); + return SendMessageA(info->hwndEdit,EM_SETLIMITTEXT,limit,0); } case EM_EXLINEFROMCHAR: TRACE_EDIT_MSG32("EM_EXLINEFROMCHAR -> LINEFROMCHAR"); - if (hwndEdit) return SendMessageA( hwndEdit, EM_LINEFROMCHAR, lParam, wParam); + if (info->hwndEdit) return SendMessageA( info->hwndEdit, EM_LINEFROMCHAR, lParam, wParam); return 0; case EM_EXSETSEL: TRACE_EDIT_MSG32("EM_EXSETSEL -> EM_SETSEL"); cr = (VOID *) lParam; - if (hwndEdit) SendMessageA( hwndEdit, EM_SETSEL, cr->cpMin, cr->cpMax); + if (info->hwndEdit) SendMessageA( info->hwndEdit, EM_SETSEL, cr->cpMin, cr->cpMax); return 0; case EM_FINDTEXT: @@ -338,7 +351,7 @@ static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, case EM_GETSELTEXT: TRACE_EDIT_MSG32("EM_GETSELTEXT"); - return RICHEDIT_GetSelText(hwndEdit,(void *)lParam); + return RICHEDIT_GetSelText(info->hwndEdit,(void *)lParam); case EM_GETTEXTEX: TRACE_EDIT_MSG32("EM_GETTEXTEX Ignored"); @@ -354,7 +367,7 @@ static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, case EM_GETTEXTRANGE: TRACE_EDIT_MSG32("EM_GETTEXTRANGE"); - return RICHEDIT_GetTextRange(hwndEdit,(TEXTRANGEA *)lParam); + return RICHEDIT_GetTextRange(info->hwndEdit,(TEXTRANGEA *)lParam); case EM_GETTYPOGRAPHYOPTIONS: TRACE_EDIT_MSG32("EM_GETTYPOGRAPHYOPTIONS Ignored"); @@ -507,139 +520,139 @@ static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, /* Messages dispatched to the edit control */ case EM_CANUNDO: TRACE_EDIT_MSG32("EM_CANUNDO Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_CHARFROMPOS: TRACE_EDIT_MSG32("EM_CHARFROMPOS Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_EMPTYUNDOBUFFER: TRACE_EDIT_MSG32("EM_EMPTYUNDOBUFFER Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_FMTLINES: TRACE_EDIT_MSG32("EM_FMTLINES Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_GETFIRSTVISIBLELINE: TRACE_EDIT_MSG32("EM_GETFIRSTVISIBLELINE Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_GETHANDLE: TRACE_EDIT_MSG32("EM_GETHANDLE Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); /* case EM_GETIMESTATUS:*/ case EM_GETLIMITTEXT: TRACE_EDIT_MSG32("EM_GETLIMITTEXT Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_GETLINE: TRACE_EDIT_MSG32("EM_GETLINE Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_GETLINECOUNT: TRACE_EDIT_MSG32("EM_GETLINECOUNT Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_GETMARGINS: TRACE_EDIT_MSG32("EM_GETMARGINS Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_GETMODIFY: TRACE_EDIT_MSG32("EM_GETMODIFY Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_GETPASSWORDCHAR: TRACE_EDIT_MSG32("EM_GETPASSWORDCHAR Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_GETRECT: TRACE_EDIT_MSG32("EM_GETRECT Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_GETSEL: TRACE_EDIT_MSG32("EM_GETSEL Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_GETTHUMB: TRACE_EDIT_MSG32("EM_GETTHUMB Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_GETWORDBREAKPROC: TRACE_EDIT_MSG32("EM_GETWORDBREAKPROC Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_LINEFROMCHAR: TRACE_EDIT_MSG32("EM_LINEFROMCHAR Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_LINEINDEX: TRACE_EDIT_MSG32("EM_LINEINDEX Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_LINELENGTH: TRACE_EDIT_MSG32("EM_LINELENGTH Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_LINESCROLL: TRACE_EDIT_MSG32("EM_LINESCROLL Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_POSFROMCHAR: TRACE_EDIT_MSG32("EM_POSFROMCHAR Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_REPLACESEL: TRACE_EDIT_MSG32("case EM_REPLACESEL Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_SCROLL: TRACE_EDIT_MSG32("case EM_SCROLL Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_SCROLLCARET: TRACE_EDIT_MSG32("EM_SCROLLCARET Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_SETHANDLE: TRACE_EDIT_MSG32("EM_SETHANDLE Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); /* case EM_SETIMESTATUS:*/ case EM_SETLIMITTEXT: TRACE_EDIT_MSG32("EM_SETLIMITTEXT Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_SETMARGINS: TRACE_EDIT_MSG32("case EM_SETMARGINS Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_SETMODIFY: TRACE_EDIT_MSG32("EM_SETMODIFY Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_SETPASSWORDCHAR: TRACE_EDIT_MSG32("EM_SETPASSWORDCHAR Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_SETREADONLY: TRACE_EDIT_MSG32("EM_SETREADONLY Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_SETRECT: TRACE_EDIT_MSG32("EM_SETRECT Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_SETRECTNP: TRACE_EDIT_MSG32("EM_SETRECTNP Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_SETSEL: TRACE_EDIT_MSG32("EM_SETSEL Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_SETTABSTOPS: TRACE_EDIT_MSG32("EM_SETTABSTOPS Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_SETWORDBREAKPROC: TRACE_EDIT_MSG32("EM_SETWORDBREAKPROC Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case EM_UNDO: TRACE_EDIT_MSG32("EM_UNDO Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case WM_STYLECHANGING: TRACE_EDIT_MSG32("WM_STYLECHANGING Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case WM_STYLECHANGED: TRACE_EDIT_MSG32("WM_STYLECHANGED Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case WM_GETTEXT: TRACE_EDIT_MSG32("WM_GETTEXT Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case WM_GETTEXTLENGTH: TRACE_EDIT_MSG32("WM_GETTEXTLENGTH Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case WM_SETTEXT: TRACE_EDIT_MSG32("WM_SETTEXT Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case WM_CUT: TRACE_EDIT_MSG32("WM_CUT Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case WM_COPY: TRACE_EDIT_MSG32("WM_COPY Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); case WM_PASTE: TRACE_EDIT_MSG32("WM_PASTE Passed to edit control"); - return SendMessageA( hwndEdit, uMsg, wParam, lParam); + return SendMessageA( info->hwndEdit, uMsg, wParam, lParam); /* Messages passed to default handler. */ case WM_NCCALCSIZE: @@ -678,6 +691,8 @@ static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, return DefWindowProcA( hwnd,uMsg,wParam,lParam); case WM_DESTROY: TRACE_EDIT_MSG32("WM_DESTROY Passed to default"); + HeapFree( GetProcessHeap(), 0, info->parser ); + HeapFree( GetProcessHeap(), 0, info ); return DefWindowProcA( hwnd,uMsg,wParam,lParam); case WM_CHILDACTIVATE: TRACE_EDIT_MSG32("WM_CHILDACTIVATE Passed to default"); diff --git a/reactos/lib/richedit/rtf.h b/reactos/lib/richedit/rtf.h index 208fbcdba8b..37059f43335 100644 --- a/reactos/lib/richedit/rtf.h +++ b/reactos/lib/richedit/rtf.h @@ -10,8 +10,6 @@ #include "winuser.h" #include "richedit.h" -void RTFSetEditStream(EDITSTREAM *es); - /* The following defines are automatically generated. Do not edit. */ @@ -420,21 +418,6 @@ void RTFSetEditStream(EDITSTREAM *es); */ -/* - * Information pertaining to last token read by RTFToken. The - * text is exactly as it occurs in the input file, e.g., "\{" - * will be found in rtfTextBuf as "\{", even though it means "{". - * These variables are also set when styles are reprocessed. - */ - -extern char *rtfTextBuf; /* text of token */ -extern int rtfTextLen; /* length of token in rtfTextBuf */ -extern int rtfClass; /* token class */ -extern int rtfMajor; /* token major number */ -extern int rtfMinor; /* token minor number */ -extern int rtfParam; /* control symbol parameter */ -extern int rtfFormat; /* either SF_RTF or SF_TEXT */ - # ifdef THINK_C # define rtfNoParam (-32768) /* 16-bit max. neg. value */ # endif @@ -442,8 +425,8 @@ extern int rtfFormat; /* either SF_RTF or SF_TEXT */ # define rtfNoParam (-1000000) # endif -extern long rtfLineNum; /* input line number */ -extern int rtfLinePos; /* input line position */ + + /* * For some reason, the no-style number is 222 @@ -1391,46 +1374,167 @@ struct RTFStyleElt }; -typedef void (*RTFFuncPtr) (); /* generic function pointer */ +#include "charlist.h" + +/* + * Return pointer to new element of type t, or NULL + * if no memory available. + */ + +# define New(t) ((t *) RTFAlloc ((int) sizeof (t))) + +/* maximum number of character values representable in a byte */ + +# define charSetSize 256 + +/* charset stack size */ + +# define maxCSStack 10 + + +struct _RTF_Info; +typedef struct _RTF_Info RTF_Info; + +typedef void (*RTFFuncPtr) (RTF_Info *); /* generic function pointer */ + +struct _RTF_Info { + /* + * Public variables (listed in rtf.h) + */ + + /* + * Information pertaining to last token read by RTFToken. The + * text is exactly as it occurs in the input file, e.g., "\{" + * will be found in rtfTextBuf as "\{", even though it means "{". + * These variables are also set when styles are reprocessed. + */ + + int rtfClass; + int rtfMajor; + int rtfMinor; + int rtfParam; + int rtfFormat; + char *rtfTextBuf; + int rtfTextLen; + + long rtfLineNum; + int rtfLinePos; + + + /* + * Private stuff + */ + + int pushedChar; /* pushback char if read too far */ + + int pushedClass; /* pushed token info for RTFUngetToken() */ + int pushedMajor; + int pushedMinor; + int pushedParam; + char *pushedTextBuf; + + int prevChar; + int bumpLine; + + RTFFont *fontList; /* these lists MUST be */ + RTFColor *colorList; /* initialized to NULL */ + RTFStyle *styleList; + + char *inputName; + char *outputName; + + EDITSTREAM editstream; + CHARLIST inputCharList ; + + /* + * These arrays are used to map RTF input character values onto the standard + * character names represented by the values. Input character values are + * used as indices into the arrays to produce standard character codes. + */ + + + char *genCharSetFile ; + int genCharCode[charSetSize]; /* general */ + int haveGenCharSet; + + char *symCharSetFile; + int symCharCode[charSetSize]; /* symbol */ + int haveSymCharSet; + + int curCharSet; + int *curCharCode; + + /* + * By default, the reader is configured to handle charset mapping invisibly, + * including reading the charset files and switching charset maps as necessary + * for Symbol font. + */ + + int autoCharSetFlags; + + /* + * Stack for keeping track of charset map on group begin/end. This is + * necessary because group termination reverts the font to the previous + * value, which may implicitly change it. + */ + + int csStack[maxCSStack]; + int csTop; + + RTFFuncPtr ccb[rtfMaxClass]; /* class callbacks */ + + RTFFuncPtr dcb[rtfMaxDestination]; /* destination callbacks */ + + RTFFuncPtr readHook; + + RTFFuncPtr panicProc; + + FILE *(*libFileOpen) (); + + char *outMap[rtfSC_MaxChar]; + + CHARLIST charlist; + +}; /* * Public RTF reader routines */ -void RTFInit (); -void RTFSetInputName (); -char *RTFGetInputName (); -void RTFSetOutputName (); -char *RTFGetOutputName (); -void RTFSetClassCallback (); -RTFFuncPtr RTFGetClassCallback (); -void RTFSetDestinationCallback (); -RTFFuncPtr RTFGetDestinationCallback (); -void RTFRead (); -int RTFGetToken (); /* writer should rarely need this */ -void RTFUngetToken (); -int RTFPeekToken (); -void RTFSetToken (); -void RTFSetReadHook (); -RTFFuncPtr RTFGetReadHook (); -void RTFRouteToken (); -void RTFSkipGroup (); -void RTFExpandStyle (); -int RTFCheckCM (); -int RTFCheckCMM (); -int RTFCheckMM (); -RTFFont *RTFGetFont (); -RTFColor *RTFGetColor (); -RTFStyle *RTFGetStyle (); +void RTFInit (RTF_Info *); +void RTFSetInputName (RTF_Info *, char *); +char *RTFGetInputName (RTF_Info *); +void RTFSetOutputName (RTF_Info *, char *); +char *RTFGetOutputName (RTF_Info *); +void RTFSetClassCallback (RTF_Info *, int, RTFFuncPtr); +RTFFuncPtr RTFGetClassCallback (RTF_Info *, int); +void RTFSetDestinationCallback (RTF_Info *, int, RTFFuncPtr); +RTFFuncPtr RTFGetDestinationCallback (RTF_Info *, int); +void RTFRead (RTF_Info *); +int RTFGetToken (RTF_Info *); /* writer should rarely need this */ +void RTFUngetToken (RTF_Info *); +int RTFPeekToken (RTF_Info *); +void RTFSetToken (RTF_Info *, int, int, int, int, char *); +void RTFSetReadHook (RTF_Info *, RTFFuncPtr); +RTFFuncPtr RTFGetReadHook (RTF_Info *); +void RTFRouteToken (RTF_Info *); +void RTFSkipGroup (RTF_Info *); +void RTFExpandStyle (RTF_Info *, int); +int RTFCheckCM (RTF_Info *, int, int); +int RTFCheckCMM (RTF_Info *, int, int, int); +int RTFCheckMM (RTF_Info *, int, int); +RTFFont *RTFGetFont (RTF_Info *, int); +RTFColor *RTFGetColor (RTF_Info *, int); +RTFStyle *RTFGetStyle (RTF_Info *, int); # define RTFAlloc(size) _RTFAlloc ((int) size) -char *_RTFAlloc (); -char *RTFStrSave (); -void RTFFree (); -int RTFCharToHex (char); -int RTFHexToChar (); -void RTFSetMsgProc (); -void RTFSetPanicProc (); +char *_RTFAlloc (int); +char *RTFStrSave (char *); +void RTFFree (char *); +int RTFCharToHex ( char); +int RTFHexToChar ( int ); +void RTFSetMsgProc ( RTFFuncPtr ); +void RTFSetPanicProc ( RTF_Info *, RTFFuncPtr); /* * The following messing around is used to allow RTFMsg() and RTFPanic() @@ -1439,20 +1543,22 @@ void RTFSetPanicProc (); * stdarg.h. */ -void RTFMsg (char *fmt, ...); -void RTFPanic (char *fmt, ...); +void RTFMsg (RTF_Info *, char *fmt, ...); +void RTFPanic (RTF_Info *, char *fmt, ...); -int RTFReadOutputMap (); -int RTFReadCharSetMap (); -void RTFSetCharSetMap (); -int RTFStdCharCode (); -char *RTFStdCharName (); -int RTFMapChar (); -int RTFGetCharSet(); -void RTFSetCharSet(); +int RTFReadOutputMap ( RTF_Info *, char *[], int); +int RTFReadCharSetMap ( RTF_Info *, int); +void RTFSetCharSetMap ( RTF_Info *, char *, int); +int RTFStdCharCode ( RTF_Info *, char *); +char *RTFStdCharName ( RTF_Info *, int); +int RTFMapChar ( RTF_Info *, int); +int RTFGetCharSet( RTF_Info * ); +void RTFSetCharSet( RTF_Info *, int); /*char *RTFGetLibPrefix();*/ -void RTFSetOpenLibFileProc (); -FILE *RTFOpenLibFile (); +void RTFSetOpenLibFileProc ( RTF_Info *, FILE *(*)()); +FILE *RTFOpenLibFile ( RTF_Info *, char *, char *); + +void RTFSetEditStream(RTF_Info *, EDITSTREAM *es); #endif diff --git a/reactos/lib/richedit/text-writer.c b/reactos/lib/richedit/text-writer.c index cad8a919b60..272a7e859e5 100644 --- a/reactos/lib/richedit/text-writer.c +++ b/reactos/lib/richedit/text-writer.c @@ -45,20 +45,22 @@ WINE_DEFAULT_DEBUG_CHANNEL(richedit); -static void TextClass (); -static void ControlClass (); -static void Destination (); -static void SpecialChar (); -static void PutStdChar (); -static void PutLitChar (); -static void PutLitStr (); +static void TextClass (RTF_Info *info); +static void ControlClass (RTF_Info *info); +static void Destination (RTF_Info *info); +static void SpecialChar (RTF_Info *info); +static void PutStdChar (RTF_Info *info, int stdCode); +static void PutLitChar (RTF_Info *info, int c); +static void PutLitStr (RTF_Info *info, char *s); +#if 0 static char *outMap[rtfSC_MaxChar]; static CHARLIST charlist = {0, NULL, NULL}; +#endif -int RTFToBuffer(char* pBuffer, int nBufferSize); -int RTFToBuffer(char* pBuffer, int nBufferSize) +/*int RTFToBuffer(char* pBuffer, int nBufferSize); */ +int RTFToBuffer(RTF_Info *info, char* pBuffer, int nBufferSize) { /* check if the buffer is big enough to hold all characters */ @@ -66,13 +68,13 @@ int RTFToBuffer(char* pBuffer, int nBufferSize) TRACE("\n"); - if(nBufferSize < charlist.nCount + 1) { - return charlist.nCount + CHARLIST_CountChar(&charlist, '\n') + 1; + if(nBufferSize < info->charlist.nCount + 1) { + return info->charlist.nCount + CHARLIST_CountChar(&info->charlist, '\n') + 1; } - while(charlist.nCount) + while(info->charlist.nCount) { - *pBuffer = CHARLIST_Dequeue(&charlist); + *pBuffer = CHARLIST_Dequeue(&info->charlist); if(*pBuffer=='\n') { *pBuffer = '\r'; @@ -92,19 +94,19 @@ int RTFToBuffer(char* pBuffer, int nBufferSize) */ void -WriterInit () +WriterInit (RTF_Info *info ) { - RTFReadOutputMap (outMap,1); + RTFReadOutputMap (info, info->outMap,1); } int -BeginFile () +BeginFile (RTF_Info *info ) { /* install class callbacks */ - RTFSetClassCallback (rtfText, TextClass); - RTFSetClassCallback (rtfControl, ControlClass); + RTFSetClassCallback (info, rtfText, TextClass); + RTFSetClassCallback (info, rtfControl, ControlClass); return (1); } @@ -119,38 +121,38 @@ BeginFile () */ static void -TextClass () +TextClass (RTF_Info *info) { char buf[rtfBufSiz]; TRACE("\n"); - if (rtfFormat == SF_TEXT) - PutLitChar (rtfMajor); - else if (rtfMinor != rtfSC_nothing) - PutStdChar (rtfMinor); + if (info->rtfFormat == SF_TEXT) + PutLitChar (info, info->rtfMajor); + else if (info->rtfMinor != rtfSC_nothing) + PutStdChar (info, info->rtfMinor); else { - if (rtfMajor < 128) /* in ASCII range */ - sprintf (buf, "[[%c]]", rtfMajor); + if (info->rtfMajor < 128) /* in ASCII range */ + sprintf (buf, "[[%c]]", info->rtfMajor); else - sprintf (buf, "[[\\'%02x]]", rtfMajor); - PutLitStr (buf); + sprintf (buf, "[[\\'%02x]]", info->rtfMajor); + PutLitStr (info, buf); } } static void -ControlClass () +ControlClass (RTF_Info *info) { TRACE("\n"); - switch (rtfMajor) + switch (info->rtfMajor) { case rtfDestination: - Destination (); + Destination (info); break; case rtfSpecialChar: - SpecialChar (); + SpecialChar (info); break; } } @@ -163,12 +165,12 @@ ControlClass () */ static void -Destination () +Destination (RTF_Info *info) { TRACE("\n"); - switch (rtfMinor) + switch (info->rtfMinor) { case rtfPict: case rtfFNContSep: @@ -183,7 +185,7 @@ Destination () case rtfIComment: case rtfIVersion: case rtfIDoccomm: - RTFSkipGroup (); + RTFSkipGroup (info); break; } } @@ -195,52 +197,52 @@ Destination () * can be controlled by the text-map file. */ -void SpecialChar () +void SpecialChar (RTF_Info *info) { TRACE("\n"); - switch (rtfMinor) + switch (info->rtfMinor) { case rtfPage: case rtfSect: case rtfRow: case rtfLine: case rtfPar: - PutLitChar ('\n'); + PutLitChar (info, '\n'); break; case rtfCell: - PutStdChar (rtfSC_space); /* make sure cells are separated */ + PutStdChar (info, rtfSC_space); /* make sure cells are separated */ break; case rtfNoBrkSpace: - PutStdChar (rtfSC_nobrkspace); + PutStdChar (info, rtfSC_nobrkspace); break; case rtfTab: - PutLitChar ('\t'); + PutLitChar (info, '\t'); break; case rtfNoBrkHyphen: - PutStdChar (rtfSC_nobrkhyphen); + PutStdChar (info, rtfSC_nobrkhyphen); break; case rtfBullet: - PutStdChar (rtfSC_bullet); + PutStdChar (info, rtfSC_bullet); break; case rtfEmDash: - PutStdChar (rtfSC_emdash); + PutStdChar (info, rtfSC_emdash); break; case rtfEnDash: - PutStdChar (rtfSC_endash); + PutStdChar (info, rtfSC_endash); break; case rtfLQuote: - PutStdChar (rtfSC_quoteleft); + PutStdChar (info, rtfSC_quoteleft); break; case rtfRQuote: - PutStdChar (rtfSC_quoteright); + PutStdChar (info, rtfSC_quoteright); break; case rtfLDblQuote: - PutStdChar (rtfSC_quotedblleft); + PutStdChar (info, rtfSC_quotedblleft); break; case rtfRDblQuote: - PutStdChar (rtfSC_quotedblright); + PutStdChar (info, rtfSC_quotedblright); break; } } @@ -255,7 +257,7 @@ void SpecialChar () * obvious and provides incentive to fix it. :-) */ -void PutStdChar (int stdCode) +void PutStdChar (RTF_Info *info, int stdCode) { char *oStr = (char *) NULL; @@ -266,28 +268,28 @@ void PutStdChar (int stdCode) */ TRACE("\n"); - oStr = outMap[stdCode]; + oStr = info->outMap[stdCode]; if (oStr == (char *) NULL) /* no output sequence in map */ { - sprintf (buf, "[[%s]]", RTFStdCharName (stdCode)); + sprintf (buf, "[[%s]]", RTFStdCharName (info, stdCode)); oStr = buf; } - PutLitStr (oStr); + PutLitStr (info, oStr); } -void PutLitChar (int c) +void PutLitChar (RTF_Info *info, int c) { - CHARLIST_Enqueue(&charlist, (char) c); + CHARLIST_Enqueue(&info->charlist, (char) c); /* fputc (c, ostream); */ } -static void PutLitStr (char *s) +static void PutLitStr (RTF_Info *info, char *s) { for(;*s;s++) { - CHARLIST_Enqueue(&charlist, *s); + CHARLIST_Enqueue(&info->charlist, *s); } /* fputs (s, ostream); */ } diff --git a/reactos/lib/richedit/winehq2ros.patch b/reactos/lib/richedit/winehq2ros.patch new file mode 100644 index 00000000000..e69de29bb2d