Dylan Smith : richedit: Simplify redundant code in WM_IME_COMPOSITION.

Alexandre Julliard julliard at winehq.org
Mon May 24 11:30:49 CDT 2010


Module: wine
Branch: master
Commit: 3f1d3e0ea14e53ebf8b4996260a9e56ca3d94b42
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=3f1d3e0ea14e53ebf8b4996260a9e56ca3d94b42

Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date:   Mon May 24 01:05:03 2010 -0400

richedit: Simplify redundant code in WM_IME_COMPOSITION.

---

 dlls/riched20/editor.c |   26 +++++++++-----------------
 1 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index e93db65..5bed094 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -4257,32 +4257,24 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
     hIMC = ITextHost_TxImmGetContext(editor->texthost);
     ME_DeleteSelection(editor);
     ME_SaveTempStyle(editor);
-    if (lParam & GCS_RESULTSTR)
+    if (lParam & (GCS_RESULTSTR|GCS_COMPSTR))
     {
         LPWSTR lpCompStr = NULL;
         DWORD dwBufLen;
+        DWORD dwIndex = lParam & GCS_RESULTSTR;
+        if (!dwIndex)
+          dwIndex = GCS_COMPSTR;
 
-        dwBufLen = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
+        dwBufLen = ImmGetCompositionStringW(hIMC, dwIndex, NULL, 0);
         lpCompStr = HeapAlloc(GetProcessHeap(),0,dwBufLen + sizeof(WCHAR));
-        ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpCompStr, dwBufLen);
+        ImmGetCompositionStringW(hIMC, dwIndex, lpCompStr, dwBufLen);
         lpCompStr[dwBufLen/sizeof(WCHAR)] = 0;
         ME_InsertTextFromCursor(editor,0,lpCompStr,dwBufLen/sizeof(WCHAR),style);
         HeapFree(GetProcessHeap(), 0, lpCompStr);
-    }
-    else if (lParam & GCS_COMPSTR)
-    {
-        LPWSTR lpCompStr = NULL;
-        DWORD dwBufLen;
 
-        dwBufLen = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
-        lpCompStr = HeapAlloc(GetProcessHeap(),0,dwBufLen + sizeof(WCHAR));
-        ImmGetCompositionStringW(hIMC, GCS_COMPSTR, lpCompStr, dwBufLen);
-        lpCompStr[dwBufLen/sizeof(WCHAR)] = 0;
-
-        ME_InsertTextFromCursor(editor,0,lpCompStr,dwBufLen/sizeof(WCHAR),style);
-        HeapFree(GetProcessHeap(), 0, lpCompStr);
-        ME_SetSelection(editor,editor->imeStartIndex,
-                        editor->imeStartIndex + dwBufLen/sizeof(WCHAR));
+        if (dwIndex == GCS_COMPSTR)
+          ME_SetSelection(editor,editor->imeStartIndex,
+                          editor->imeStartIndex + dwBufLen/sizeof(WCHAR));
     }
     ME_ReleaseStyle(style);
     ME_CommitUndo(editor);




More information about the wine-cvs mailing list