Commit 3fe15349 authored by Jinoh Kang's avatar Jinoh Kang Committed by Alexandre Julliard

riched20: Implement ITextDocument::Freeze and ITextDocument::Unfreeze.

parent 2027be7e
...@@ -2994,6 +2994,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) ...@@ -2994,6 +2994,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
ed->mode |= (ed->props & TXTBIT_RICHTEXT) ? TM_RICHTEXT : TM_PLAINTEXT; ed->mode |= (ed->props & TXTBIT_RICHTEXT) ? TM_RICHTEXT : TM_PLAINTEXT;
ed->AutoURLDetect_bEnable = FALSE; ed->AutoURLDetect_bEnable = FALSE;
ed->bHaveFocus = FALSE; ed->bHaveFocus = FALSE;
ed->freeze_count = 0;
ed->bMouseCaptured = FALSE; ed->bMouseCaptured = FALSE;
ed->caret_hidden = FALSE; ed->caret_hidden = FALSE;
ed->caret_height = 0; ed->caret_height = 0;
......
...@@ -429,6 +429,7 @@ typedef struct tagME_TextEditor ...@@ -429,6 +429,7 @@ typedef struct tagME_TextEditor
BOOL AutoURLDetect_bEnable; BOOL AutoURLDetect_bEnable;
WCHAR password_char; WCHAR password_char;
BOOL bHaveFocus; BOOL bHaveFocus;
DWORD freeze_count;
/*for IME */ /*for IME */
int imeStartIndex; int imeStartIndex;
DWORD selofs; /* The size of the selection bar on the left side of control */ DWORD selofs; /* The size of the selection bar on the left side of control */
......
...@@ -123,6 +123,7 @@ void ME_Repaint(ME_TextEditor *editor) ...@@ -123,6 +123,7 @@ void ME_Repaint(ME_TextEditor *editor)
ME_UpdateScrollBar(editor); ME_UpdateScrollBar(editor);
FIXME("ME_Repaint had to call ME_WrapMarkedParagraphs\n"); FIXME("ME_Repaint had to call ME_WrapMarkedParagraphs\n");
} }
if (!editor->freeze_count)
ITextHost_TxViewChange(editor->texthost, TRUE); ITextHost_TxViewChange(editor->texthost, TRUE);
} }
...@@ -140,6 +141,7 @@ void ME_UpdateRepaint(ME_TextEditor *editor, BOOL update_now) ...@@ -140,6 +141,7 @@ void ME_UpdateRepaint(ME_TextEditor *editor, BOOL update_now)
update_caret( editor ); update_caret( editor );
if (!editor->freeze_count)
ITextHost_TxViewChange(editor->texthost, update_now); ITextHost_TxViewChange(editor->texthost, update_now);
ME_SendSelChange(editor); ME_SendSelChange(editor);
......
...@@ -4217,15 +4217,22 @@ static HRESULT WINAPI ITextDocument2Old_fnSave(ITextDocument2Old *iface, VARIANT ...@@ -4217,15 +4217,22 @@ static HRESULT WINAPI ITextDocument2Old_fnSave(ITextDocument2Old *iface, VARIANT
static HRESULT WINAPI ITextDocument2Old_fnFreeze(ITextDocument2Old *iface, LONG *pCount) static HRESULT WINAPI ITextDocument2Old_fnFreeze(ITextDocument2Old *iface, LONG *pCount)
{ {
struct text_services *services = impl_from_ITextDocument2Old(iface); 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) static HRESULT WINAPI ITextDocument2Old_fnUnfreeze(ITextDocument2Old *iface, LONG *pCount)
{ {
struct text_services *services = impl_from_ITextDocument2Old(iface); 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) static HRESULT WINAPI ITextDocument2Old_fnBeginEditCollection(ITextDocument2Old *iface)
......
...@@ -5518,9 +5518,7 @@ static void test_freeze(void) ...@@ -5518,9 +5518,7 @@ static void test_freeze(void)
count = 0xdeadbeef; count = 0xdeadbeef;
hr = ITextDocument_Freeze(doc, &count); hr = ITextDocument_Freeze(doc, &count);
todo_wine
ok(hr == S_OK, "ITextDocument_Freeze returned %#lx\n", hr); 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); ok(count == 1, "expected count to be %d, got %ld\n", 1, count);
style2 = GetWindowLongW(hwnd, GWL_STYLE); style2 = GetWindowLongW(hwnd, GWL_STYLE);
...@@ -5528,54 +5526,40 @@ static void test_freeze(void) ...@@ -5528,54 +5526,40 @@ static void test_freeze(void)
count = 0xdeadbeef; count = 0xdeadbeef;
hr = ITextDocument_Freeze(doc, &count); hr = ITextDocument_Freeze(doc, &count);
todo_wine
ok(hr == S_OK, "ITextDocument_Freeze returned %#lx\n", hr); 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); ok(count == 2, "expected count to be %d, got %ld\n", 2, count);
count = 0xdeadbeef; count = 0xdeadbeef;
hr = ITextDocument_Unfreeze(doc, &count); hr = ITextDocument_Unfreeze(doc, &count);
todo_wine
ok(hr == S_FALSE, "ITextDocument_Unfreeze returned %#lx\n", hr); 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); ok(count == 1, "expected count to be %d, got %ld\n", 1, count);
count = 0xdeadbeef; count = 0xdeadbeef;
hr = ITextDocument_Unfreeze(doc, &count); hr = ITextDocument_Unfreeze(doc, &count);
todo_wine
ok(hr == S_OK, "ITextDocument_Unfreeze returned %#lx\n", hr); 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); ok(count == 0, "expected count to be %d, got %ld\n", 0, count);
count = 0xdeadbeef; count = 0xdeadbeef;
hr = ITextDocument_Unfreeze(doc, &count); hr = ITextDocument_Unfreeze(doc, &count);
todo_wine
ok(hr == S_OK, "ITextDocument_Unfreeze returned %#lx\n", hr); 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); ok(count == 0, "expected count to be %d, got %ld\n", 0, count);
count = 0xdeadbeef; count = 0xdeadbeef;
hr = ITextDocument_Freeze(doc, &count); hr = ITextDocument_Freeze(doc, &count);
todo_wine
ok(hr == S_OK, "ITextDocument_Freeze returned %#lx\n", hr); 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); ok(count == 1, "expected count to be %d, got %ld\n", 1, count);
count = 0xdeadbeef; count = 0xdeadbeef;
hr = ITextDocument_Unfreeze(doc, &count); hr = ITextDocument_Unfreeze(doc, &count);
todo_wine
ok(hr == S_OK, "ITextDocument_Unfreeze returned %#lx\n", hr); 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); ok(count == 0, "expected count to be %d, got %ld\n", 0, count);
count = 0xdeadbeef; count = 0xdeadbeef;
hr = ITextDocument_Freeze(doc, NULL); hr = ITextDocument_Freeze(doc, NULL);
todo_wine
ok(hr == S_OK, "ITextDocument_Freeze returned %#lx\n", hr); ok(hr == S_OK, "ITextDocument_Freeze returned %#lx\n", hr);
count = 0xdeadbeef; count = 0xdeadbeef;
hr = ITextDocument_Unfreeze(doc, NULL); hr = ITextDocument_Unfreeze(doc, NULL);
todo_wine
ok(hr == S_OK, "ITextDocument_Unfreeze returned %#lx\n", hr); ok(hr == S_OK, "ITextDocument_Unfreeze returned %#lx\n", hr);
release_interfaces(&hwnd, &reole, &doc, &selection); release_interfaces(&hwnd, &reole, &doc, &selection);
......
...@@ -863,9 +863,7 @@ static void test_TxDraw(void) ...@@ -863,9 +863,7 @@ static void test_TxDraw(void)
freeze_count = 0xdeadbeef; freeze_count = 0xdeadbeef;
hr = ITextDocument_Freeze( txtdoc, &freeze_count ); hr = ITextDocument_Freeze( txtdoc, &freeze_count );
todo_wine
ok( hr == S_OK, "ITextDocument_Freeze returned %#lx\n", hr ); 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 ); 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, hr = ITextServices_TxDraw( txtserv, DVASPECT_CONTENT, 0, NULL, NULL, hdc, NULL, (RECTL *)&client, NULL,
...@@ -873,14 +871,11 @@ static void test_TxDraw(void) ...@@ -873,14 +871,11 @@ static void test_TxDraw(void)
ok( hr == S_OK, "got %08lx\n", hr ); ok( hr == S_OK, "got %08lx\n", hr );
hr = ITextServices_TxDraw( txtserv, DVASPECT_CONTENT, 0, NULL, NULL, hdc, NULL, (RECTL *)&client, NULL, hr = ITextServices_TxDraw( txtserv, DVASPECT_CONTENT, 0, NULL, NULL, hdc, NULL, (RECTL *)&client, NULL,
NULL, NULL, 0, TXTVIEW_ACTIVE ); NULL, NULL, 0, TXTVIEW_ACTIVE );
todo_wine
ok( hr == E_UNEXPECTED, "got %08lx\n", hr ); ok( hr == E_UNEXPECTED, "got %08lx\n", hr );
freeze_count = 0xdeadbeef; freeze_count = 0xdeadbeef;
hr = ITextDocument_Unfreeze( txtdoc, &freeze_count ); hr = ITextDocument_Unfreeze( txtdoc, &freeze_count );
todo_wine
ok( hr == S_OK, "ITextDocument_Unfreeze returned %#lx\n", hr ); 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 ); ok( freeze_count == 0, "expected count to be %d, got %ld\n", 0, freeze_count );
hr = ITextServices_OnTxInPlaceDeactivate( txtserv ); hr = ITextServices_OnTxInPlaceDeactivate( txtserv );
......
...@@ -1313,18 +1313,22 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, ...@@ -1313,18 +1313,22 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
RECT rc, client, update; RECT rc, client, update;
PAINTSTRUCT ps; PAINTSTRUCT ps;
HBRUSH brush, old_brush; HBRUSH brush, old_brush;
LONG view_id;
ITextHost_TxGetClientRect( &host->ITextHost_iface, &client ); ITextHost_TxGetClientRect( &host->ITextHost_iface, &client );
if (msg == WM_PAINT) if (msg == WM_PAINT)
{ {
/* TODO retrieve if the text document is frozen */
hdc = BeginPaint( hwnd, &ps ); hdc = BeginPaint( hwnd, &ps );
update = ps.rcPaint; update = ps.rcPaint;
view_id = TXTVIEW_ACTIVE;
} }
else else
{ {
hdc = (HDC)wparam; hdc = (HDC)wparam;
update = client; update = client;
view_id = TXTVIEW_INACTIVE;
} }
brush = CreateSolidBrush( ITextHost_TxGetSysColor( &host->ITextHost_iface, COLOR_WINDOW ) ); brush = CreateSolidBrush( ITextHost_TxGetSysColor( &host->ITextHost_iface, COLOR_WINDOW ) );
...@@ -1361,7 +1365,7 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam, ...@@ -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, 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 ); SelectObject( hdc, old_brush );
DeleteObject( brush ); DeleteObject( brush );
if (msg == WM_PAINT) EndPaint( hwnd, &ps ); if (msg == WM_PAINT) EndPaint( hwnd, &ps );
......
...@@ -168,6 +168,8 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxDraw( ITextServices *iface, DWORD ...@@ -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 ) if (aspect != DVASPECT_CONTENT || aspect_info || td || target || mf_bounds || continue_fn )
FIXME( "Many arguments are ignored\n" ); 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 ); hr = update_client_rect( services, (RECT *)bounds );
if (FAILED( hr )) return hr; if (FAILED( hr )) return hr;
if (hr == S_OK) rewrap = TRUE; if (hr == S_OK) rewrap = TRUE;
......
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