Signed-off-by: Sergio Gómez Del Real sdelreal@codeweavers.com --- dlls/riched20/editor.c | 17 ++++------------- dlls/riched20/editstr.h | 1 + dlls/riched20/para.c | 1 + dlls/riched20/wrap.c | 10 ++++++---- 4 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index bf4c8ea0c2..052400c99f 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -3036,6 +3036,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) ed->styleFlags = 0; ed->exStyleFlags = 0; ed->first_marked_para = NULL; + ed->total_rows = 0; ITextHost_TxGetPropertyBits(texthost, (TXTBIT_RICHTEXT|TXTBIT_MULTILINE| TXTBIT_READONLY|TXTBIT_USEPASSWORD| @@ -4215,22 +4216,12 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, } case EM_GETLINECOUNT: { - ME_DisplayItem *item = editor->pBuffer->pFirst->next; - int nRows = 0; - + ME_DisplayItem *item = editor->pBuffer->pLast; + int nRows = editor->total_rows; ME_DisplayItem *prev_para = NULL, *last_para = NULL;
- while (item != editor->pBuffer->pLast) - { - assert(item->type == diParagraph); - prev_para = ME_FindItemBack(item, diRun); - if (prev_para) { - assert(prev_para->member.run.nFlags & MERF_ENDPARA); - } - nRows += item->member.para.nRows; - item = item->member.para.next_para; - } last_para = ME_FindItemBack(item, diRun); + prev_para = ME_FindItemBack(last_para, diRun); assert(last_para); assert(last_para->member.run.nFlags & MERF_ENDPARA); if (editor->bEmulateVersion10 && prev_para && diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h index 2cd16c93c8..96c9a1f644 100644 --- a/dlls/riched20/editstr.h +++ b/dlls/riched20/editstr.h @@ -397,6 +397,7 @@ typedef struct tagME_TextEditor int nTotalWidth, nLastTotalWidth; int nAvailWidth; /* 0 = wrap to client area, else wrap width in twips */ int nUDArrowX; + int total_rows; COLORREF rgbBackColor; HBRUSH hbrBackground; BOOL bCaretAtEnd; diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c index aaa2bda06a..c4ddb65d4e 100644 --- a/dlls/riched20/para.c +++ b/dlls/riched20/para.c @@ -54,6 +54,7 @@ void destroy_para(ME_TextEditor *editor, ME_DisplayItem *item) item->member.para.nWidth = 0; editor->nTotalWidth = get_total_width(editor); } + editor->total_rows -= item->member.para.nRows; ME_DestroyString(item->member.para.text); para_num_clear( &item->member.para.para_num ); remove_marked_para(editor, item); diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c index c2e3f62162..c3444943f0 100644 --- a/dlls/riched20/wrap.c +++ b/dlls/riched20/wrap.c @@ -733,12 +733,13 @@ static int ME_GetParaLineSpace(ME_Context* c, ME_Paragraph* para) return sp * c->editor->nZoomNumerator / c->editor->nZoomDenominator; }
-static void ME_PrepareParagraphForWrapping(ME_Context *c, ME_DisplayItem *tp) { +static void ME_PrepareParagraphForWrapping(ME_TextEditor *editor, ME_Context *c, ME_DisplayItem *tp) { ME_DisplayItem *p;
tp->member.para.nWidth = 0; /* remove row start items as they will be reinserted by the * paragraph wrapper anyway */ + editor->total_rows -= tp->member.para.nRows; tp->member.para.nRows = 0; for (p = tp->next; p != tp->member.para.next_para; p = p->next) { if (p->type == diStartRow) { @@ -870,7 +871,7 @@ static HRESULT shape_para( ME_Context *c, ME_DisplayItem *p ) return hr; }
-static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp) { +static void ME_WrapTextParagraph(ME_TextEditor *editor, ME_Context *c, ME_DisplayItem *tp) { ME_DisplayItem *p; ME_WrapContext wc; int border = 0; @@ -881,7 +882,7 @@ static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp) { if (!(tp->member.para.nFlags & MEPF_REWRAP)) { return; } - ME_PrepareParagraphForWrapping(c, tp); + ME_PrepareParagraphForWrapping(editor, c, tp);
/* Calculate paragraph numbering label */ para_num_init( c, &tp->member.para ); @@ -969,6 +970,7 @@ static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp) { tp->member.para.nFlags &= ~MEPF_REWRAP; tp->member.para.nHeight = wc.pt.y; tp->member.para.nRows = wc.nRow; + editor->total_rows += wc.nRow; }
static void ME_MarkRepaintEnd(ME_DisplayItem *para, @@ -1114,7 +1116,7 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) assert(item->type == diParagraph);
prev_width = item->member.para.nWidth; - ME_WrapTextParagraph(&c, item); + ME_WrapTextParagraph(editor, &c, item); if (prev_width == totalWidth && item->member.para.nWidth < totalWidth) totalWidth = get_total_width(editor); else