Huw Davies : riched20: Pass a ME_Paragraph ptr to itemize_para().

Alexandre Julliard julliard at winehq.org
Thu Oct 8 15:20:05 CDT 2020


Module: wine
Branch: master
Commit: 7ef2c6c8d516107750040e2a23e6ade222e46794
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=7ef2c6c8d516107750040e2a23e6ade222e46794

Author: Huw Davies <huw at codeweavers.com>
Date:   Thu Oct  8 11:10:48 2020 +0100

riched20: Pass a ME_Paragraph ptr to itemize_para().

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/riched20/editor.h |  1 +
 dlls/riched20/para.c   | 13 +++++++++++++
 dlls/riched20/wrap.c   | 29 ++++++++---------------------
 3 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 922a1e5c6c..47e822c2d3 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -211,6 +211,7 @@ int get_total_width(ME_TextEditor *editor) DECLSPEC_HIDDEN;
 void mark_para_rewrap(ME_TextEditor *editor, ME_DisplayItem *para) DECLSPEC_HIDDEN;
 void add_marked_para(ME_TextEditor *editor, ME_DisplayItem *para) DECLSPEC_HIDDEN;
 void remove_marked_para(ME_TextEditor *editor, ME_DisplayItem *para) DECLSPEC_HIDDEN;
+ME_Run *para_first_run( ME_Paragraph *para ) DECLSPEC_HIDDEN;
 static inline ME_DisplayItem *para_get_di(ME_Paragraph *para)
 {
     return (ME_DisplayItem *)((ptrdiff_t)para - offsetof(ME_DisplayItem, member));
diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c
index 7cef6ca993..fb994506be 100644
--- a/dlls/riched20/para.c
+++ b/dlls/riched20/para.c
@@ -143,6 +143,19 @@ void add_marked_para(ME_TextEditor *editor, ME_DisplayItem *di)
     }
 }
 
+ME_Run *para_first_run( ME_Paragraph *para )
+{
+    ME_DisplayItem *di;
+
+    for (di = para_get_di( para ); di != para->next_para; di = di->next )
+    {
+        if (di->type != diRun) continue;
+        return &di->member.run;
+    }
+    ERR( "failed to find run in paragraph\n" );
+    return NULL;
+}
+
 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 13a54829b2..48db31f4ff 100644
--- a/dlls/riched20/wrap.c
+++ b/dlls/riched20/wrap.c
@@ -719,11 +719,9 @@ static void ME_PrepareParagraphForWrapping( ME_TextEditor *editor, ME_Context *c
     }
 }
 
-static HRESULT itemize_para( ME_Context *c, ME_DisplayItem *p )
+static HRESULT itemize_para( ME_Context *c, ME_Paragraph *para )
 {
-    ME_Paragraph *para = &p->member.para;
     ME_Run *run;
-    ME_DisplayItem *di;
     SCRIPT_ITEM buf[16], *items = buf;
     int items_passed = ARRAY_SIZE( buf ), num_items, cur_item;
     SCRIPT_CONTROL control = { LANG_USER_DEFAULT, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
@@ -731,8 +729,6 @@ static HRESULT itemize_para( ME_Context *c, ME_DisplayItem *p )
     SCRIPT_STATE state = { 0, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 0, 0 };
     HRESULT hr;
 
-    assert( p->type == diParagraph );
-
     if (para->fmt.dwMask & PFM_RTLPARA && para->fmt.wEffects & PFE_RTLPARA)
         state.uBidiLevel = 1;
 
@@ -763,19 +759,13 @@ static HRESULT itemize_para( ME_Context *c, ME_DisplayItem *p )
         }
 
         TRACE( "before splitting runs into ranges\n" );
-        for (di = p->next; di != p->member.para.next_para; di = di->next)
-        {
-            if (di->type != diRun) continue;
-            TRACE( "\t%d: %s\n", di->member.run.nCharOfs, debugstr_run( &di->member.run ) );
-        }
+        for (run = para_first_run( para ); run; run = run_next( run ))
+            TRACE( "\t%d: %s\n", run->nCharOfs, debugstr_run( run ) );
     }
 
     /* split runs into ranges at item boundaries */
-    for (di = p->next, cur_item = 0; di != p->member.para.next_para; di = di->next)
+    for (run = para_first_run( para ), cur_item = 0; run; run = run_next( run ))
     {
-        if (di->type != diRun) continue;
-        run = &di->member.run;
-
         if (run->nCharOfs == items[cur_item+1].iCharPos) cur_item++;
 
         items[cur_item].a.fLogicalOrder = TRUE;
@@ -785,7 +775,7 @@ static HRESULT itemize_para( ME_Context *c, ME_DisplayItem *p )
 
         if (run->nCharOfs + run->len > items[cur_item+1].iCharPos)
         {
-            ME_Cursor cursor = {p, di, items[cur_item+1].iCharPos - run->nCharOfs};
+            ME_Cursor cursor = {para_get_di( para ), run_get_di( run ), items[cur_item+1].iCharPos - run->nCharOfs};
             ME_SplitRunSimple( c->editor, &cursor );
         }
     }
@@ -793,11 +783,8 @@ static HRESULT itemize_para( ME_Context *c, ME_DisplayItem *p )
     if (TRACE_ON( richedit ))
     {
         TRACE( "after splitting into ranges\n" );
-        for (di = p->next; di != p->member.para.next_para; di = di->next)
-        {
-            if (di->type != diRun) continue;
-            TRACE( "\t%d: %s\n", di->member.run.nCharOfs, debugstr_run( &di->member.run ) );
-        }
+        for (run = para_first_run( para ); run; run = run_next( run ))
+            TRACE( "\t%d: %s\n", run->nCharOfs, debugstr_run( run ) );
     }
 
     para->nFlags |= MEPF_COMPLEX;
@@ -847,7 +834,7 @@ static void ME_WrapTextParagraph( ME_TextEditor *editor, ME_Context *c, ME_Parag
   if (!c->editor->cPasswordMask /* &&
       ScriptIsComplex( tp->member.para.text->szData, tp->member.para.text->nLen, SIC_COMPLEX ) == S_OK */)
   {
-      if (SUCCEEDED( itemize_para( c, para_get_di( para ) ) ))
+      if (SUCCEEDED( itemize_para( c, para ) ))
           shape_para( c, para_get_di( para ) );
   }
 




More information about the wine-cvs mailing list