[PATCH 2/5] riched20: Call ITextHost_TxGetCharFormat() for setting default charformat.
Signed-off-by: Jactry Zeng <jzeng(a)codeweavers.com> --- dlls/riched20/para.c | 12 ++++++++++++ dlls/riched20/tests/txtsrv.c | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c index f2a70e5746..e5e1c4be3c 100644 --- a/dlls/riched20/para.c +++ b/dlls/riched20/para.c @@ -36,6 +36,7 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor) { ME_Context c; CHARFORMAT2W cf; + const CHARFORMATW *host_cf; LOGFONTW lf; HFONT hf; ME_TextBuffer *text = editor->pBuffer; @@ -44,6 +45,7 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor) ME_Style *style; int eol_len; WCHAR cr_lf[] = {'\r','\n',0}; + HRESULT hr; ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost)); @@ -73,6 +75,16 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor) cf.bCharSet = lf.lfCharSet; cf.lcid = GetSystemDefaultLCID(); + /* replace some default charformat setting with charformat from host */ + hr = ITextHost_TxGetCharFormat(editor->texthost, (const CHARFORMATW **)&host_cf); + if (hr == S_OK) + { + if (host_cf->dwMask & CFM_FACE) + lstrcpyW(cf.szFaceName, host_cf->szFaceName); + if (host_cf->dwMask & CFM_SIZE) + cf.yHeight = host_cf->yHeight; + } + style = ME_MakeStyle(&cf); text->pDefaultStyle = style; diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c index 88b5adf13c..4dd205a596 100644 --- a/dlls/riched20/tests/txtsrv.c +++ b/dlls/riched20/tests/txtsrv.c @@ -85,6 +85,7 @@ typedef struct ITextHostTestImpl { ITextHost ITextHost_iface; LONG refCount; + CHARFORMATW char_format; } ITextHostTestImpl; static inline ITextHostTestImpl *impl_from_ITextHost(ITextHost *iface) @@ -330,7 +331,8 @@ static HRESULT WINAPI ITextHostImpl_TxGetCharFormat(ITextHost *iface, { ITextHostTestImpl *This = impl_from_ITextHost(iface); TRACECALL("Call to TxGetCharFormat(%p, ppCF=%p)\n", This, ppCF); - return E_NOTIMPL; + *ppCF = &This->char_format; + return S_OK; } static HRESULT WINAPI ITextHostImpl_TxGetParaFormat(ITextHost *iface, @@ -609,6 +611,8 @@ static BOOL init_texthost(ITextServices **txtserv, ITextHost **ret) ITextHostTestImpl *dummyTextHost; IUnknown *init; HRESULT result; + LOGFONTW lf; + HFONT hf; dummyTextHost = CoTaskMemAlloc(sizeof(*dummyTextHost)); if (dummyTextHost == NULL) { @@ -617,6 +621,13 @@ static BOOL init_texthost(ITextServices **txtserv, ITextHost **ret) } dummyTextHost->ITextHost_iface.lpVtbl = &itextHostVtbl; dummyTextHost->refCount = 1; + memset(&dummyTextHost->char_format, 0, sizeof(dummyTextHost->char_format)); + dummyTextHost->char_format.cbSize = sizeof(dummyTextHost->char_format); + dummyTextHost->char_format.dwMask = CFM_FACE | CFM_SIZE; + hf = (HFONT)GetStockObject(DEFAULT_GUI_FONT); + GetObjectW(hf, sizeof(LOGFONTW), &lf); + lstrcpyW(dummyTextHost->char_format.szFaceName, lf.lfFaceName); + dummyTextHost->char_format.yHeight = MulDiv(abs(lf.lfHeight), 1440, GetDeviceCaps(GetDC(NULL), LOGPIXELSY)); /* MSDN states that an IUnknown object is returned by CreateTextServices which is then queried to obtain a @@ -950,6 +961,33 @@ static void test_QueryInterface(void) ITextHost_Release(host); } +static void test_default_format(void) +{ + ITextServices *txtserv; + ITextHost *host; + HRESULT result; + LRESULT lresult; + CHARFORMAT2W cf2; + HFONT hf; + LOGFONTW lf; + LONG expected_height; + + if (!init_texthost(&txtserv, &host)) + return; + + cf2.cbSize = sizeof(CHARFORMAT2W); + result = ITextServices_TxSendMessage(txtserv, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf2, &lresult); + ok(result == S_OK, "ITextServices_TxSendMessage failed: 0x%08x.\n", result); + hf = (HFONT)GetStockObject(DEFAULT_GUI_FONT); + GetObjectW(hf, sizeof(LOGFONTW), &lf); + expected_height = MulDiv(abs(lf.lfHeight), 1440, GetDeviceCaps(GetDC(NULL), LOGPIXELSY)); + ok(!lstrcmpW(lf.lfFaceName, cf2.szFaceName), "got wrong font name: %s.\n", wine_dbgstr_w(cf2.szFaceName)); + ok(cf2.yHeight == expected_height, "got wrong yHeight: %d, expetced %d.\n", cf2.yHeight, expected_height); + + ITextServices_Release(txtserv); + ITextHost_Release(host); +} + START_TEST( txtsrv ) { ITextServices *txtserv; @@ -980,6 +1018,7 @@ START_TEST( txtsrv ) test_TxGetNaturalSize(); test_TxDraw(); test_QueryInterface(); + test_default_format(); } if (wrapperCodeMem) VirtualFree(wrapperCodeMem, 0, MEM_RELEASE); } -- 2.15.1 (Apple Git-101)
Hi, While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at https://testbot.winehq.org/JobDetails.pl?Key=38577 Your paranoid android. === wxppro (32 bit txtsrv) === txtsrv.c:772: Test failed: Height calculated incorrectly (expected 16, got 2) txtsrv.c:776: Test failed: Width calculated incorrectly (expected 8 {+1}, got 3) === w2003std (32 bit txtsrv) === txtsrv.c:772: Test failed: Height calculated incorrectly (expected 16, got 2) txtsrv.c:776: Test failed: Width calculated incorrectly (expected 8 {+1}, got 3) === wvistau64 (32 bit txtsrv) === txtsrv.c:772: Test failed: Height calculated incorrectly (expected 16, got 2) txtsrv.c:776: Test failed: Width calculated incorrectly (expected 8 {+1}, got 3) === wvistau64_zh_CN (32 bit txtsrv) === txtsrv.c:772: Test failed: Height calculated incorrectly (expected 16, got 2) txtsrv.c:776: Test failed: Width calculated incorrectly (expected 8 {+1}, got 3) === wvistau64_fr (32 bit txtsrv) === txtsrv.c:772: Test failed: Height calculated incorrectly (expected 16, got 2) txtsrv.c:776: Test failed: Width calculated incorrectly (expected 8 {+1}, got 3) === w2008s64 (32 bit txtsrv) === txtsrv.c:772: Test failed: Height calculated incorrectly (expected 16, got 2) txtsrv.c:776: Test failed: Width calculated incorrectly (expected 8 {+1}, got 3) === w7u (32 bit txtsrv) === txtsrv.c:772: Test failed: Height calculated incorrectly (expected 18, got 2) txtsrv.c:776: Test failed: Width calculated incorrectly (expected 11 {+1}, got 2) === w7pro64 (32 bit txtsrv) === txtsrv.c:772: Test failed: Height calculated incorrectly (expected 16, got 2) txtsrv.c:776: Test failed: Width calculated incorrectly (expected 8 {+1}, got 3) === w8 (32 bit txtsrv) === txtsrv.c:772: Test failed: Height calculated incorrectly (expected 16, got 2) txtsrv.c:776: Test failed: Width calculated incorrectly (expected 8 {+1}, got 3) === w864 (32 bit txtsrv) === txtsrv.c:772: Test failed: Height calculated incorrectly (expected 16, got 2) txtsrv.c:776: Test failed: Width calculated incorrectly (expected 8 {+1}, got 3) === w1064 (32 bit txtsrv) === txtsrv.c:772: Test failed: Height calculated incorrectly (expected 16, got 2) txtsrv.c:776: Test failed: Width calculated incorrectly (expected 8 {+1}, got 3) === wvistau64 (64 bit txtsrv) === txtsrv.c:772: Test failed: Height calculated incorrectly (expected 16, got 2) txtsrv.c:776: Test failed: Width calculated incorrectly (expected 8 {+1}, got 3) === w2008s64 (64 bit txtsrv) === txtsrv.c:772: Test failed: Height calculated incorrectly (expected 16, got 2) txtsrv.c:776: Test failed: Width calculated incorrectly (expected 8 {+1}, got 3) === w7pro64 (64 bit txtsrv) === txtsrv.c:772: Test failed: Height calculated incorrectly (expected 16, got 2) txtsrv.c:776: Test failed: Width calculated incorrectly (expected 8 {+1}, got 3) The previous 2 run(s) terminated abnormally === w864 (64 bit txtsrv) === txtsrv.c:772: Test failed: Height calculated incorrectly (expected 16, got 2) txtsrv.c:776: Test failed: Width calculated incorrectly (expected 8 {+1}, got 3) === w1064 (64 bit txtsrv) === txtsrv.c:772: Test failed: Height calculated incorrectly (expected 16, got 2) txtsrv.c:776: Test failed: Width calculated incorrectly (expected 8 {+1}, got 3)
participants (2)
-
Jactry Zeng -
Marvin