diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index f67b9e70f10..0223b30f810 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -256,6 +256,7 @@ BOOL ME_GetYScrollVisible(ME_TextEditor *editor); /* other functions in paint.c */ int ME_GetParaBorderWidth(ME_TextEditor *editor, int); +int ME_GetParaLineSpace(ME_TextEditor *editor, ME_Paragraph*, int); /* richole.c */ extern LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *); diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c index 72c03f14315..3d4349646eb 100644 --- a/dlls/riched20/paint.c +++ b/dlls/riched20/paint.c @@ -365,6 +365,29 @@ int ME_GetParaBorderWidth(ME_TextEditor* editor, int flags) return width; } +int ME_GetParaLineSpace(ME_TextEditor* editor, ME_Paragraph* para, int dpi) +{ + int sp = 0, ls = 0; + if (!(para->pFmt->dwMask & PFM_LINESPACING)) return 0; + + /* FIXME: how to compute simply the line space in ls ??? */ + /* FIXME: does line spacing include the line itself ??? */ + switch (para->pFmt->bLineSpacingRule) + { + case 0: sp = ls; break; + case 1: sp = (3 * ls) / 2; break; + case 2: sp = 2 * ls; break; + case 3: sp = para->pFmt->dyLineSpacing * dpi / 1440; if (sp < ls) sp = ls; break; + case 4: sp = para->pFmt->dyLineSpacing * dpi / 1440; break; + case 5: sp = para->pFmt->dyLineSpacing / 20; break; + default: FIXME("Unsupported spacing rule value %d\n", para->pFmt->bLineSpacingRule); + } + if (editor->nZoomNumerator == 0) + return sp; + else + return sp * editor->nZoomNumerator / editor->nZoomDenominator; +} + static int ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y, int dpi) { int idx, border_width; diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c index d1f6203dbd3..f0b2c49d999 100644 --- a/dlls/riched20/wrap.c +++ b/dlls/riched20/wrap.c @@ -343,6 +343,7 @@ static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp, DWORD begino ME_WrapContext wc; int dpi = GetDeviceCaps(c->hDC, LOGPIXELSX); int border = 0; + int linespace = 0; assert(tp->type == diParagraph); if (!(tp->member.para.nFlags & MEPF_REWRAP)) { @@ -378,14 +379,17 @@ static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp, DWORD begino wc.nAvailWidth = wc.nTotalWidth - wc.nFirstMargin - wc.nRightMargin; wc.pRowStart = NULL; + linespace = ME_GetParaLineSpace(c->editor, &tp->member.para, dpi); + ME_BeginRow(&wc); for (p = tp->next; p!=tp->member.para.next_para; ) { assert(p->type != diStartRow); if (p->type == diRun) { p = ME_WrapHandleRun(&wc, p); - continue; } - p = p->next; + else p = p->next; + if (wc.nRow && p == wc.pRowStart) + wc.pt.y += linespace; } ME_WrapEndParagraph(&wc, p); if ((tp->member.para.pFmt->dwMask & PFM_BORDER) && (tp->member.para.pFmt->wBorders & 8))