Module: wine Branch: stable Commit: 1f5a64a59db353c6f7320c1f58497bcabe508a7a URL: https://gitlab.winehq.org/wine/wine/-/commit/1f5a64a59db353c6f7320c1f58497bc...
Author: Jinoh Kang jinoh.kang.kr@gmail.com Date: Sat Mar 4 23:12:16 2023 +0900
riched20: Implement ITextDocument::Freeze and ITextDocument::Unfreeze.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54617 (cherry picked from commit 3fe15349d39ccf31026a92eae30f83f65c91cb1f)
---
dlls/riched20/editor.c | 1 + dlls/riched20/editstr.h | 1 + dlls/riched20/paint.c | 6 ++++-- dlls/riched20/richole.c | 15 +++++++++++---- dlls/riched20/tests/richole.c | 16 ---------------- dlls/riched20/tests/txtsrv.c | 5 ----- dlls/riched20/txthost.c | 6 +++++- dlls/riched20/txtsrv.c | 2 ++ 8 files changed, 24 insertions(+), 28 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 7b4f4b3cdf3..2c7176f09c1 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2986,6 +2986,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) ed->mode |= (ed->props & TXTBIT_RICHTEXT) ? TM_RICHTEXT : TM_PLAINTEXT; ed->AutoURLDetect_bEnable = FALSE; ed->bHaveFocus = FALSE; + ed->freeze_count = 0; ed->bMouseCaptured = FALSE; ed->caret_hidden = FALSE; ed->caret_height = 0; diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h index db219d7e4df..cc577de14db 100644 --- a/dlls/riched20/editstr.h +++ b/dlls/riched20/editstr.h @@ -429,6 +429,7 @@ typedef struct tagME_TextEditor BOOL AutoURLDetect_bEnable; WCHAR password_char; BOOL bHaveFocus; + DWORD freeze_count; /*for IME */ int imeStartIndex; DWORD selofs; /* The size of the selection bar on the left side of control */ diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c index 245afff77dc..8bc1b8bcd2f 100644 --- a/dlls/riched20/paint.c +++ b/dlls/riched20/paint.c @@ -123,7 +123,8 @@ void ME_Repaint(ME_TextEditor *editor) ME_UpdateScrollBar(editor); FIXME("ME_Repaint had to call ME_WrapMarkedParagraphs\n"); } - ITextHost_TxViewChange(editor->texthost, TRUE); + if (!editor->freeze_count) + ITextHost_TxViewChange(editor->texthost, TRUE); }
void ME_UpdateRepaint(ME_TextEditor *editor, BOOL update_now) @@ -140,7 +141,8 @@ void ME_UpdateRepaint(ME_TextEditor *editor, BOOL update_now)
update_caret( editor );
- ITextHost_TxViewChange(editor->texthost, update_now); + if (!editor->freeze_count) + ITextHost_TxViewChange(editor->texthost, update_now);
ME_SendSelChange(editor);
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index 8190a4e2753..90496742e36 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -4217,15 +4217,22 @@ static HRESULT WINAPI ITextDocument2Old_fnSave(ITextDocument2Old *iface, VARIANT static HRESULT WINAPI ITextDocument2Old_fnFreeze(ITextDocument2Old *iface, LONG *pCount) { struct text_services *services = impl_from_ITextDocument2Old(iface); - FIXME("stub %p\n", services); - return E_NOTIMPL; + + if (services->editor->freeze_count < LONG_MAX) services->editor->freeze_count++; + + if (pCount) *pCount = services->editor->freeze_count; + return services->editor->freeze_count != 0 ? S_OK : S_FALSE; }
static HRESULT WINAPI ITextDocument2Old_fnUnfreeze(ITextDocument2Old *iface, LONG *pCount) { struct text_services *services = impl_from_ITextDocument2Old(iface); - FIXME("stub %p\n", services); - return E_NOTIMPL; + + if (services->editor->freeze_count && !--services->editor->freeze_count) + ME_RewrapRepaint(services->editor); + + if (pCount) *pCount = services->editor->freeze_count; + return services->editor->freeze_count == 0 ? S_OK : S_FALSE; }
static HRESULT WINAPI ITextDocument2Old_fnBeginEditCollection(ITextDocument2Old *iface) diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index 529291b5fd1..16c6481691f 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -5466,9 +5466,7 @@ static void test_freeze(void)
count = 0xdeadbeef; hr = ITextDocument_Freeze(doc, &count); - todo_wine ok(hr == S_OK, "ITextDocument_Freeze returned %#lx\n", hr); - todo_wine ok(count == 1, "expected count to be %d, got %ld\n", 1, count);
style2 = GetWindowLongW(hwnd, GWL_STYLE); @@ -5476,54 +5474,40 @@ static void test_freeze(void)
count = 0xdeadbeef; hr = ITextDocument_Freeze(doc, &count); - todo_wine ok(hr == S_OK, "ITextDocument_Freeze returned %#lx\n", hr); - todo_wine ok(count == 2, "expected count to be %d, got %ld\n", 2, count);
count = 0xdeadbeef; hr = ITextDocument_Unfreeze(doc, &count); - todo_wine ok(hr == S_FALSE, "ITextDocument_Unfreeze returned %#lx\n", hr); - todo_wine ok(count == 1, "expected count to be %d, got %ld\n", 1, count);
count = 0xdeadbeef; hr = ITextDocument_Unfreeze(doc, &count); - todo_wine ok(hr == S_OK, "ITextDocument_Unfreeze returned %#lx\n", hr); - todo_wine ok(count == 0, "expected count to be %d, got %ld\n", 0, count);
count = 0xdeadbeef; hr = ITextDocument_Unfreeze(doc, &count); - todo_wine ok(hr == S_OK, "ITextDocument_Unfreeze returned %#lx\n", hr); - todo_wine ok(count == 0, "expected count to be %d, got %ld\n", 0, count);
count = 0xdeadbeef; hr = ITextDocument_Freeze(doc, &count); - todo_wine ok(hr == S_OK, "ITextDocument_Freeze returned %#lx\n", hr); - todo_wine ok(count == 1, "expected count to be %d, got %ld\n", 1, count);
count = 0xdeadbeef; hr = ITextDocument_Unfreeze(doc, &count); - todo_wine ok(hr == S_OK, "ITextDocument_Unfreeze returned %#lx\n", hr); - todo_wine ok(count == 0, "expected count to be %d, got %ld\n", 0, count);
count = 0xdeadbeef; hr = ITextDocument_Freeze(doc, NULL); - todo_wine ok(hr == S_OK, "ITextDocument_Freeze returned %#lx\n", hr);
count = 0xdeadbeef; hr = ITextDocument_Unfreeze(doc, NULL); - todo_wine ok(hr == S_OK, "ITextDocument_Unfreeze returned %#lx\n", hr);
release_interfaces(&hwnd, &reole, &doc, &selection); diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c index 2777f4eea21..da8e9da5ea6 100644 --- a/dlls/riched20/tests/txtsrv.c +++ b/dlls/riched20/tests/txtsrv.c @@ -863,9 +863,7 @@ static void test_TxDraw(void)
freeze_count = 0xdeadbeef; hr = ITextDocument_Freeze( txtdoc, &freeze_count ); - todo_wine ok( hr == S_OK, "ITextDocument_Freeze returned %#lx\n", hr ); - todo_wine ok( freeze_count == 1, "expected count to be %d, got %ld\n", 1, freeze_count );
hr = ITextServices_TxDraw( txtserv, DVASPECT_CONTENT, 0, NULL, NULL, hdc, NULL, (RECTL *)&client, NULL, @@ -873,14 +871,11 @@ static void test_TxDraw(void) ok( hr == S_OK, "got %08lx\n", hr ); hr = ITextServices_TxDraw( txtserv, DVASPECT_CONTENT, 0, NULL, NULL, hdc, NULL, (RECTL *)&client, NULL, NULL, NULL, 0, TXTVIEW_ACTIVE ); - todo_wine ok( hr == E_UNEXPECTED, "got %08lx\n", hr );
freeze_count = 0xdeadbeef; hr = ITextDocument_Unfreeze( txtdoc, &freeze_count ); - todo_wine ok( hr == S_OK, "ITextDocument_Unfreeze returned %#lx\n", hr ); - todo_wine ok( freeze_count == 0, "expected count to be %d, got %ld\n", 0, freeze_count );
hr = ITextServices_OnTxInPlaceDeactivate( txtserv ); diff --git a/dlls/riched20/txthost.c b/dlls/riched20/txthost.c index ec6f8e52fa5..412733edaeb 100644 --- a/dlls/riched20/txthost.c +++ b/dlls/riched20/txthost.c @@ -1313,18 +1313,22 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, RECT rc, client, update; PAINTSTRUCT ps; HBRUSH brush, old_brush; + LONG view_id;
ITextHost_TxGetClientRect( &host->ITextHost_iface, &client );
if (msg == WM_PAINT) { + /* TODO retrieve if the text document is frozen */ hdc = BeginPaint( hwnd, &ps ); update = ps.rcPaint; + view_id = TXTVIEW_ACTIVE; } else { hdc = (HDC)wparam; update = client; + view_id = TXTVIEW_INACTIVE; }
brush = CreateSolidBrush( ITextHost_TxGetSysColor( &host->ITextHost_iface, COLOR_WINDOW ) ); @@ -1361,7 +1365,7 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, }
ITextServices_TxDraw( host->text_srv, DVASPECT_CONTENT, 0, NULL, NULL, hdc, NULL, NULL, NULL, - &update, NULL, 0, TXTVIEW_ACTIVE ); + &update, NULL, 0, view_id ); SelectObject( hdc, old_brush ); DeleteObject( brush ); if (msg == WM_PAINT) EndPaint( hwnd, &ps ); diff --git a/dlls/riched20/txtsrv.c b/dlls/riched20/txtsrv.c index 809bb5ac3ae..55e0c7e64bb 100644 --- a/dlls/riched20/txtsrv.c +++ b/dlls/riched20/txtsrv.c @@ -168,6 +168,8 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxDraw( ITextServices *iface, DWORD if (aspect != DVASPECT_CONTENT || aspect_info || td || target || mf_bounds || continue_fn ) FIXME( "Many arguments are ignored\n" );
+ if (view_id == TXTVIEW_ACTIVE && services->editor->freeze_count) return E_UNEXPECTED; + hr = update_client_rect( services, (RECT *)bounds ); if (FAILED( hr )) return hr; if (hr == S_OK) rewrap = TRUE;