Commit c8e2552a authored by Dylan Smith's avatar Dylan Smith Committed by Alexandre Julliard

richedit: Trailing spaces should not affect alignment shift length.

parent 308582b4
...@@ -58,21 +58,47 @@ static void ME_BeginRow(ME_WrapContext *wc) ...@@ -58,21 +58,47 @@ static void ME_BeginRow(ME_WrapContext *wc)
static void ME_InsertRowStart(ME_WrapContext *wc, const ME_DisplayItem *pEnd) static void ME_InsertRowStart(ME_WrapContext *wc, const ME_DisplayItem *pEnd)
{ {
ME_DisplayItem *p, *row, *para; ME_DisplayItem *p, *row, *para;
BOOL bSkippingSpaces = TRUE;
int ascent = 0, descent = 0, width=0, shift = 0, align = 0; int ascent = 0, descent = 0, width=0, shift = 0, align = 0;
/* wrap text */ /* wrap text */
para = ME_GetParagraph(wc->pRowStart); para = ME_GetParagraph(wc->pRowStart);
for (p = wc->pRowStart; p!=pEnd; p = p->next)
for (p = pEnd->prev; p!=wc->pRowStart->prev; p = p->prev)
{ {
/* ENDPARA run shouldn't affect row height, except if it's the only run in the paragraph */ /* ENDPARA run shouldn't affect row height, except if it's the only run in the paragraph */
if (p->type==diRun && ((p==wc->pRowStart) || !(p->member.run.nFlags & MERF_ENDPARA))) { /* FIXME add more run types */ if (p->type==diRun && ((p==wc->pRowStart) || !(p->member.run.nFlags & MERF_ENDPARA))) { /* FIXME add more run types */
if (p->member.run.nAscent>ascent) if (p->member.run.nAscent>ascent)
ascent = p->member.run.nAscent; ascent = p->member.run.nAscent;
if (p->member.run.nDescent>descent) if (p->member.run.nDescent>descent)
descent = p->member.run.nDescent; descent = p->member.run.nDescent;
if (!(p->member.run.nFlags & (MERF_ENDPARA|MERF_SKIPPED))) if (bSkippingSpaces)
width += p->member.run.nWidth; {
} /* Exclude space characters from run width.
* Other whitespace or delimiters are not treated this way. */
SIZE sz;
int len = p->member.run.strText->nLen;
WCHAR *text = p->member.run.strText->szData + len - 1;
assert (len);
while (len && *(text--) == ' ')
len--;
if (len)
{
if (len == p->member.run.strText->nLen)
{
width += p->member.run.nWidth;
} else {
sz = ME_GetRunSize(wc->context, &para->member.para,
&p->member.run, len, p->member.run.pt.x);
width += sz.cx;
}
}
bSkippingSpaces = !len;
} else if (!(p->member.run.nFlags & MERF_ENDPARA))
width += p->member.run.nWidth;
}
} }
row = ME_MakeRow(ascent+descent, ascent, width); row = ME_MakeRow(ascent+descent, ascent, width);
row->member.row.nYPos = wc->pt.y; row->member.row.nYPos = wc->pt.y;
row->member.row.nLMargin = (!wc->nRow ? wc->nFirstMargin : wc->nLeftMargin); row->member.row.nLMargin = (!wc->nRow ? wc->nFirstMargin : wc->nLeftMargin);
...@@ -98,7 +124,7 @@ static void ME_InsertRowStart(ME_WrapContext *wc, const ME_DisplayItem *pEnd) ...@@ -98,7 +124,7 @@ static void ME_InsertRowStart(ME_WrapContext *wc, const ME_DisplayItem *pEnd)
static void ME_WrapEndParagraph(ME_WrapContext *wc, ME_DisplayItem *p) static void ME_WrapEndParagraph(ME_WrapContext *wc, ME_DisplayItem *p)
{ {
if (wc->pRowStart) if (wc->pRowStart)
ME_InsertRowStart(wc, p->next); ME_InsertRowStart(wc, p);
/* /*
p = p->member.para.prev_para->next; p = p->member.para.prev_para->next;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment