Merge branch 'master3' into 'master'

user32: Fix the number of characters processed by DrawTextExW.

See merge request wine/wine!4812
This commit is contained in:
JiangYi Chen 2024-11-19 01:36:48 +00:00
commit 8ff15e9bd5
2 changed files with 34 additions and 4 deletions

View file

@ -656,6 +656,30 @@ static void test_DrawTextCalcRect(void)
ok(rect.top == rect2.top, "unexpected value %ld, got %ld\n", rect.top, rect2.top);
ok(rect.bottom == rect2.bottom , "unexpected value %ld, got %ld\n", rect.bottom, rect2.bottom);
/* further tests for dtp */
SelectObject(hdc, hOldFont);
ret = DeleteObject(hFont);
ok(ret, "DeleteObject error %lu\n", GetLastError());
lf.lfHeight = 200 * 9 / 72;
hFont = CreateFontIndirectA(&lf);
ok(hFont != 0, "CreateFontIndirectA error %lu\n", GetLastError());
hOldFont = SelectObject(hdc, hFont);
SetRect( &rect, 0,0, 100, 25);
memset(&dtp, 0, sizeof(dtp));
dtp.cbSize = sizeof(dtp);
textheight = DrawTextExW(hdc, textW, lstrlenW(textW), &rect, DT_EDITCONTROL | DT_NOPREFIX | DT_WORDBREAK, &dtp);
todo_wine ok(dtp.uiLengthDrawn == 10, "Unexpected uiLengthDrawn %d\n", dtp.uiLengthDrawn );
memset(&dtp, 0, sizeof(dtp));
dtp.cbSize = sizeof(dtp);
textheight = DrawTextExW(hdc, (LPWSTR)L" a1b2c3", lstrlenW(L" a1b2c3"), &rect, DT_EDITCONTROL | DT_NOPREFIX | DT_WORDBREAK, &dtp);
todo_wine ok(dtp.uiLengthDrawn == 7, "Unexpected uiLengthDrawn %d\n", dtp.uiLengthDrawn );
memset(&dtp, 0, sizeof(dtp));
dtp.cbSize = sizeof(dtp);
textheight = DrawTextExW(hdc, (LPWSTR)L"a 1\tb2c3", lstrlenW(L"a 1\tb2c3"), &rect, DT_EDITCONTROL | DT_NOPREFIX | DT_WORDBREAK, &dtp);
todo_wine ok(dtp.uiLengthDrawn == 8, "Unexpected uiLengthDrawn %d\n", dtp.uiLengthDrawn );
SelectObject(hdc, hOldFont);
ret = DeleteObject(hFont);

View file

@ -1021,10 +1021,13 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
}
len -= len_seg;
str += len_seg;
if (dtp) dtp->uiLengthDrawn += len_seg;
if (len)
{
assert ((flags & DT_EXPANDTABS) && *str == TAB);
len--; str++;
if (dtp) dtp->uiLengthDrawn++;
xseg += ((size.cx/tabwidth)+1)*tabwidth;
if (prefix_offset != -1)
{
@ -1044,15 +1047,18 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
}
}
}
else if (size.cx > max_width)
max_width = size.cx;
else
{
if (dtp) dtp->uiLengthDrawn += len;
if (size.cx > max_width)
max_width = size.cx;
}
if (invert_y)
y -= lh;
else
y += lh;
if (dtp)
dtp->uiLengthDrawn += len;
}
while (strPtr && !last_line);