From 577ea0cbc3521a4cfaf6827f47308061fe392bf6 Mon Sep 17 00:00:00 2001 From: Duane Clark Date: Mon, 8 Jul 2002 19:37:18 +0000 Subject: [PATCH] Add richedit support for a plain text stream. --- dlls/richedit/reader.c | 18 +++++++++++++++--- dlls/richedit/richedit.c | 1 + dlls/richedit/rtf.h | 1 + dlls/richedit/text-writer.c | 6 ++++-- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/dlls/richedit/reader.c b/dlls/richedit/reader.c index e2a64a39623..cee61e10b89 100644 --- a/dlls/richedit/reader.c +++ b/dlls/richedit/reader.c @@ -123,6 +123,7 @@ int rtfClass; int rtfMajor; int rtfMinor; int rtfParam; +int rtfFormat; char *rtfTextBuf = (char *) NULL; int rtfTextLen; @@ -540,9 +541,8 @@ RTFFuncPtr p; (*p) (); /* give read hook a look at token */ /* Silently discard newlines, carriage returns, nulls. */ - if (!(rtfClass == rtfText - && (rtfMajor == '\n' || rtfMajor == '\r' - || rtfMajor == '\0'))) + if (!(rtfClass == rtfText && rtfFormat != SF_TEXT + && (rtfMajor == '\r' || rtfMajor == '\n' || rtfMajor == '\0'))) break; } return (rtfClass); @@ -604,6 +604,18 @@ RTFFont *fp; TRACE("\n"); + if (rtfFormat == SF_TEXT) { + rtfMajor = GetChar (); + rtfMinor = rtfSC_nothing; + rtfParam = rtfNoParam; + rtfTextBuf[rtfTextLen = 0] = '\0'; + if (rtfMajor == EOF) + rtfClass = rtfEOF; + else + rtfClass = rtfText; + return; + } + /* first check for pushed token from RTFUngetToken() */ if (pushedClass >= 0) diff --git a/dlls/richedit/richedit.c b/dlls/richedit/richedit.c index 9af1dee01fe..85c189fd174 100644 --- a/dlls/richedit/richedit.c +++ b/dlls/richedit/richedit.c @@ -175,6 +175,7 @@ static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, /* setup the RTF parser */ RTFSetEditStream(( EDITSTREAM*)lParam); + rtfFormat = wParam&(SF_TEXT|SF_RTF); WriterInit(); RTFInit (); BeginFile(); diff --git a/dlls/richedit/rtf.h b/dlls/richedit/rtf.h index 0feb3d7e9e2..95b99e95a32 100644 --- a/dlls/richedit/rtf.h +++ b/dlls/richedit/rtf.h @@ -432,6 +432,7 @@ 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 */ diff --git a/dlls/richedit/text-writer.c b/dlls/richedit/text-writer.c index 678aa253872..0285114870c 100644 --- a/dlls/richedit/text-writer.c +++ b/dlls/richedit/text-writer.c @@ -124,8 +124,10 @@ TextClass () char buf[rtfBufSiz]; TRACE("\n"); - - if (rtfMinor != rtfSC_nothing) + + if (rtfFormat == SF_TEXT) + PutLitChar (rtfMajor); + else if (rtfMinor != rtfSC_nothing) PutStdChar (rtfMinor); else {