diff options
author | Yohei Yukawa <yukawa@google.com> | 2013-05-06 14:20:11 +0900 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2013-05-13 05:14:37 +0000 |
commit | 57b5ed51d46fd5673dfe35125ceffa71d39f133d (patch) | |
tree | c6dcc9991647a7869451a15ba436cb7443f1dc06 /vcl/win | |
parent | c0417e82174297ace604c68fc577c831929f3573 (diff) |
Support IMR_QUERYCHARPOSITION in Writer and Calc.
IMR_QUERYCHARPOSITION is one of optional but fundamental request
message sent from IMEs to application. This message is used for
retrieving the positional information for each character in a
composition text especially when the composition text is drawn
by the application.
This information is critical for IMEs to align suggestion window
with the composition text.
Change-Id: I53a344a78688060004cc8bcbbf1127f22a468e20
Reviewed-on: https://gerrit.libreoffice.org/3849
Reviewed-by: Tor Lillqvist <tml@iki.fi>
Tested-by: Tor Lillqvist <tml@iki.fi>
Diffstat (limited to 'vcl/win')
-rw-r--r-- | vcl/win/source/window/salframe.cxx | 56 |
1 files changed, 51 insertions, 5 deletions
diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx index 05ecefdb44d1..574519c3f5a2 100644 --- a/vcl/win/source/window/salframe.cxx +++ b/vcl/win/source/window/salframe.cxx @@ -5523,6 +5523,47 @@ static LRESULT ImplHandleIMEConfirmReconvertString( HWND hWnd, LPARAM lParam ) return TRUE; } +static LRESULT ImplHandleIMEQueryCharPosition( HWND hWnd, LPARAM lParam ) { + WinSalFrame* pFrame = GetWindowPtr( hWnd ); + PIMECHARPOSITION pQueryCharPosition = (PIMECHARPOSITION) lParam; + if ( pQueryCharPosition->dwSize < sizeof(IMECHARPOSITION) ) + return FALSE; + + SalQueryCharPositionEvent aEvt; + aEvt.mbValid = false; + aEvt.mnCharPos = pQueryCharPosition->dwCharPos; + + pFrame->CallCallback( SALEVENT_QUERYCHARPOSITION, (void*)&aEvt ); + + if ( !aEvt.mbValid ) + return FALSE; + + if ( aEvt.mbVertical ) + { + // For vertical writing, the base line is left edge of the rectangle + // and the target position is top-right corner. + pQueryCharPosition->pt.x = aEvt.mnCursorBoundX + aEvt.mnCursorBoundWidth; + pQueryCharPosition->pt.y = aEvt.mnCursorBoundY; + pQueryCharPosition->cLineHeight = aEvt.mnCursorBoundWidth; + } + else + { + // For horizontal writing, the base line is the bottom edge of the rectangle. + // and the target position is top-left corner. + pQueryCharPosition->pt.x = aEvt.mnCursorBoundX; + pQueryCharPosition->pt.y = aEvt.mnCursorBoundY; + pQueryCharPosition->cLineHeight = aEvt.mnCursorBoundHeight; + } + + // Currently not supported but many IMEs usually ignore them. + pQueryCharPosition->rcDocument.left = 0; + pQueryCharPosition->rcDocument.top = 0; + pQueryCharPosition->rcDocument.right = 0; + pQueryCharPosition->rcDocument.bottom = 0; + + return TRUE; +} + #endif // WINVER >= 0x0500 // ----------------------------------------------------------------------- @@ -5945,11 +5986,16 @@ LRESULT CALLBACK SalFrameWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lP nRet = ImplHandleIMEReconvertString( hWnd, lParam ); rDef = FALSE; } - else if( (sal_uIntPtr)( wParam ) == IMR_CONFIRMRECONVERTSTRING ) - { - nRet = ImplHandleIMEConfirmReconvertString( hWnd, lParam ); - rDef = FALSE; - } + else if( (sal_uIntPtr)( wParam ) == IMR_CONFIRMRECONVERTSTRING ) + { + nRet = ImplHandleIMEConfirmReconvertString( hWnd, lParam ); + rDef = FALSE; + } + else if ( (sal_uIntPtr)( wParam ) == IMR_QUERYCHARPOSITION ) + { + nRet = ImplHandleIMEQueryCharPosition( hWnd, lParam ); + rDef = FALSE; + } break; #endif // WINVER >= 0x0500 } |