tdf#70633 unset Alt if detected as AltGr in both KeyInput branches

we are unsetting Alt if the modifier is AltGr in one SalEvent::KeyInput
case but not in another. If I replicate the unset of Alt if AlrGr in
the other place then both UTF-16 parts of the codepoint get accepted
and the described input case works

Change-Id: Ifa8a5afbb1853ef3d5f388fd5e7bd3bbc048e260
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118170
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 8e4abcdb..45361d8 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -3353,6 +3353,16 @@ bool WinSalFrame::MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangT
    return bRet;
}

static void UnsetAltIfAltGr(SalKeyEvent& rKeyEvt, sal_uInt16 nModCode)
{
    if ((nModCode & (KEY_MOD1 | KEY_MOD2)) == (KEY_MOD1 | KEY_MOD2) &&
        rKeyEvt.mnCharCode)
    {
        // this is actually AltGr and should not be handled as Alt
        rKeyEvt.mnCode &= ~(KEY_MOD1 | KEY_MOD2);
    }
}

static bool ImplHandleKeyMsg( HWND hWnd, UINT nMsg,
                              WPARAM wParam, LPARAM lParam, LRESULT& rResult )
{
@@ -3441,8 +3451,12 @@ static bool ImplHandleKeyMsg( HWND hWnd, UINT nMsg,
        aKeyEvt.mnCode     |= nModCode;
        aKeyEvt.mnCharCode  = ImplGetCharCode( pFrame, wParam );
        aKeyEvt.mnRepeat    = nRepeat;

        UnsetAltIfAltGr(aKeyEvt, nModCode);

        nLastChar = 0;
        nLastVKChar = 0;

        bool nRet = pFrame->CallCallback( SalEvent::KeyInput, &aKeyEvt );
        pFrame->CallCallback( SalEvent::KeyUp, &aKeyEvt );
        return nRet;
@@ -3593,12 +3607,7 @@ static bool ImplHandleKeyMsg( HWND hWnd, UINT nMsg,
                aKeyEvt.mnCode     |= nModCode;
                aKeyEvt.mnRepeat    = nRepeat;

                if ((nModCode & (KEY_MOD1 | KEY_MOD2)) == (KEY_MOD1 | KEY_MOD2) &&
                    aKeyEvt.mnCharCode)
                {
                    // this is actually AltGr and should not be handled as Alt
                    aKeyEvt.mnCode &= ~(KEY_MOD1 | KEY_MOD2);
                }
                UnsetAltIfAltGr(aKeyEvt, nModCode);

                bIgnoreCharMsg = bCharPeek;
                bool nRet = pFrame->CallCallback( nEvent, &aKeyEvt );