From be3073fce1586bc2d5a888007f89cde510392964 Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Sat, 17 Jul 2010 15:29:28 -0400 Subject: [PATCH] richedit: Fix streaming rtf with table at the start of the text. The first paragraph was being handled just by ME_StreamOutParaProps, but subsequent paragraphs would check if the paragraph was starting or ending a table. So I moved the code to check for tables into ME_StreamOutParaProps. --- dlls/riched20/writer.c | 71 +++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/dlls/riched20/writer.c b/dlls/riched20/writer.c index dfc4dd44bc0..8c8714504b8 100644 --- a/dlls/riched20/writer.c +++ b/dlls/riched20/writer.c @@ -406,12 +406,44 @@ ME_StreamOutRTFTableProps(ME_TextEditor *editor, ME_OutStream *pStream, static BOOL ME_StreamOutRTFParaProps(ME_TextEditor *editor, ME_OutStream *pStream, - const ME_DisplayItem *para) + ME_DisplayItem *para) { PARAFORMAT2 *fmt = para->member.para.pFmt; char props[STREAMOUT_BUFFER_SIZE] = ""; int i; - + + if (!editor->bEmulateVersion10) { /* v4.1 */ + if (para->member.para.nFlags & MEPF_ROWSTART) { + pStream->nNestingLevel++; + if (pStream->nNestingLevel == 1) { + if (!ME_StreamOutRTFTableProps(editor, pStream, para)) + return FALSE; + } + return TRUE; + } else if (para->member.para.nFlags & MEPF_ROWEND) { + pStream->nNestingLevel--; + if (pStream->nNestingLevel >= 1) { + if (!ME_StreamOutPrint(pStream, "{\\*\\nesttableprops")) + return FALSE; + if (!ME_StreamOutRTFTableProps(editor, pStream, para)) + return FALSE; + if (!ME_StreamOutPrint(pStream, "\\nestrow}{\\nonesttables\\par}\r\n")) + return FALSE; + } else { + if (!ME_StreamOutPrint(pStream, "\\row \r\n")) + return FALSE; + } + return TRUE; + } + } else { /* v1.0 - 3.0 */ + if (para->member.para.pFmt->dwMask & PFM_TABLE && + para->member.para.pFmt->wEffects & PFE_TABLE) + { + if (!ME_StreamOutRTFTableProps(editor, pStream, para)) + return FALSE; + } + } + /* TODO: Don't emit anything if the last PARAFORMAT2 is inherited */ if (!ME_StreamOutPrint(pStream, "\\pard")) return FALSE; @@ -798,39 +830,8 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream, if (cursor.pPara != prev_para) { prev_para = cursor.pPara; - if (!editor->bEmulateVersion10) { /* v4.1 */ - if (cursor.pPara->member.para.nFlags & MEPF_ROWSTART) { - pStream->nNestingLevel++; - if (pStream->nNestingLevel == 1) { - if (!ME_StreamOutRTFTableProps(editor, pStream, cursor.pPara)) - return FALSE; - } - } else if (cursor.pPara->member.para.nFlags & MEPF_ROWEND) { - pStream->nNestingLevel--; - if (pStream->nNestingLevel >= 1) { - if (!ME_StreamOutPrint(pStream, "{\\*\\nesttableprops")) - return FALSE; - if (!ME_StreamOutRTFTableProps(editor, pStream, cursor.pPara)) - return FALSE; - if (!ME_StreamOutPrint(pStream, "\\nestrow}{\\nonesttables\\par}\r\n")) - return FALSE; - } else { - if (!ME_StreamOutPrint(pStream, "\\row \r\n")) - return FALSE; - } - } else if (!ME_StreamOutRTFParaProps(editor, pStream, cursor.pPara)) { - return FALSE; - } - } else { /* v1.0 - 3.0 */ - if (cursor.pPara->member.para.pFmt->dwMask & PFM_TABLE && - cursor.pPara->member.para.pFmt->wEffects & PFE_TABLE) - { - if (!ME_StreamOutRTFTableProps(editor, pStream, cursor.pPara)) - return FALSE; - } - if (!ME_StreamOutRTFParaProps(editor, pStream, cursor.pPara)) - return FALSE; - } + if (!ME_StreamOutRTFParaProps(editor, pStream, cursor.pPara)) + return FALSE; } if (cursor.pRun == endCur.pRun && !endCur.nOffset)