[PATCH 4/5] riched20: Start re-wrap loop at the beginning of any table.

Huw Davies huw at codeweavers.com
Tue Oct 20 06:50:37 CDT 2020


This ensures that cell heights of cells before the first marked
cell are correctly adjusted.

Fixes last part of a regression caused by commit
195f84cfa1b81d3b526dde64f614169d5da5d86c

Signed-off-by: Huw Davies <huw at codeweavers.com>
---
 dlls/riched20/editor.h |  1 +
 dlls/riched20/para.c   |  5 +++++
 dlls/riched20/wrap.c   | 16 +++++++++++++---
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index c79fa0e18f0..1f74a2eb8b4 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -207,6 +207,7 @@ int get_total_width(ME_TextEditor *editor) DECLSPEC_HIDDEN;
 void para_destroy( ME_TextEditor *editor, ME_Paragraph *item ) DECLSPEC_HIDDEN;
 ME_Run *para_end_run( ME_Paragraph *para ) DECLSPEC_HIDDEN;
 ME_Run *para_first_run( ME_Paragraph *para ) DECLSPEC_HIDDEN;
+BOOL para_in_table( ME_Paragraph *para ) DECLSPEC_HIDDEN;
 ME_Paragraph *para_join( ME_TextEditor *editor, ME_Paragraph *para, BOOL use_first_fmt ) DECLSPEC_HIDDEN;
 void para_mark_add( ME_TextEditor *editor, ME_Paragraph *para ) DECLSPEC_HIDDEN;
 void para_mark_remove( ME_TextEditor *editor, ME_Paragraph *para ) DECLSPEC_HIDDEN;
diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c
index 0e1ceae9bbb..1db553a3478 100644
--- a/dlls/riched20/para.c
+++ b/dlls/riched20/para.c
@@ -119,6 +119,11 @@ ME_Run *para_end_run( ME_Paragraph *para )
     return para->eop_run;
 }
 
+BOOL para_in_table( ME_Paragraph *para )
+{
+    return para->fmt.wEffects & PFE_TABLE;
+}
+
 void ME_MakeFirstParagraph(ME_TextEditor *editor)
 {
   static const WCHAR cr_lf[] = {'\r','\n',0};
diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c
index aae95a59ce2..4f6eb82cea7 100644
--- a/dlls/riched20/wrap.c
+++ b/dlls/riched20/wrap.c
@@ -1026,7 +1026,7 @@ static void adjust_para_y( ME_Paragraph *para, ME_Context *c, struct repaint_ran
 BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
 {
   ME_Paragraph *para, *next;
-  struct wine_rb_entry *entry, *next_entry;
+  struct wine_rb_entry *entry, *next_entry = NULL;
   ME_Context c;
   int totalWidth = editor->nTotalWidth, prev_width;
   struct repaint_range repaint = { NULL, NULL };
@@ -1039,7 +1039,16 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
   while (entry)
   {
     para = WINE_RB_ENTRY_VALUE( entry, ME_Paragraph, marked_entry );
-    next_entry = wine_rb_next( entry );
+
+    /* If the first entry lies inside a table, go back to the start
+       of the table to ensure cell heights are kept in sync. */
+    if (!next_entry && para_in_table( para ) && para != table_outer_para( para ))
+    {
+        para = table_outer_para( para );
+        next_entry = entry;
+    }
+    else
+        next_entry = wine_rb_next( entry );
 
     c.pt = para->pt;
     prev_width = para->nWidth;
@@ -1054,7 +1063,8 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
 
     if (para_next( para ))
     {
-      if (c.pt.x != para_next( para )->pt.x || c.pt.y != para_next( para )->pt.y)
+      if (c.pt.x != para_next( para )->pt.x || c.pt.y != para_next( para )->pt.y ||
+          para_in_table( para ))
       {
         next = para;
         while (para_next( next ) && &next->marked_entry != next_entry &&
-- 
2.23.0




More information about the wine-devel mailing list