[2/2] richedit: Fix streaming rtf with table at the start of the text. (resend)

Dylan Smith dylan.ah.smith at gmail.com
Sat Jul 17 14:29:28 CDT 2010


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 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/dlls/riched20/writer.c b/dlls/riched20/writer.c
index dfc4dd4..8c87145 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)
-- 
1.7.0.4



More information about the wine-patches mailing list