summaryrefslogtreecommitdiffstats
path: root/vcl/win
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 09:29:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 09:29:03 +0000
commit5a7157d319477830426797532e02ac39d3b859f4 (patch)
tree3773f5ce209bee14a5643e98672e0f3828c71434 /vcl/win
parentReleasing progress-linux version 4:24.2.0-3~progress7.99u1. (diff)
downloadlibreoffice-5a7157d319477830426797532e02ac39d3b859f4.tar.xz
libreoffice-5a7157d319477830426797532e02ac39d3b859f4.zip
Merging upstream version 4:24.2.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/gdi/salprn.cxx19
-rw-r--r--vcl/win/window/salframe.cxx126
2 files changed, 144 insertions, 1 deletions
diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx
index 3302efa2d9..065b060196 100644
--- a/vcl/win/gdi/salprn.cxx
+++ b/vcl/win/gdi/salprn.cxx
@@ -1196,6 +1196,25 @@ OUString WinSalInfoPrinter::GetPaperBinName( const ImplJobSetup* pSetupData, sal
return aPaperBinName;
}
+sal_uInt16 WinSalInfoPrinter::GetPaperBinBySourceIndex( const ImplJobSetup* pSetupData, sal_uInt16 nPaperSource )
+{
+ DWORD nBins = ImplDeviceCaps( this, DC_BINNAMES, nullptr, pSetupData );
+ if (nBins != GDI_ERROR)
+ {
+ auto pBuffer = std::make_unique<sal_uInt16[]>(nBins);
+ DWORD nBins = ImplDeviceCaps( this, DC_BINS, reinterpret_cast<BYTE*>(pBuffer.get()), pSetupData );
+ if (nBins != GDI_ERROR)
+ {
+ for (DWORD nBin = 0; nBin < nBins; ++nBin)
+ {
+ if (nPaperSource == *(pBuffer.get() + nBin))
+ return nBin;
+ }
+ }
+ }
+ return 0xffff;
+}
+
sal_uInt32 WinSalInfoPrinter::GetCapabilities( const ImplJobSetup* pSetupData, PrinterCapType nType )
{
DWORD nRet;
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index cf2c8c6f8b..1eed596e6c 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -3522,6 +3522,125 @@ static void FlushIMBeforeShortCut(WinSalFrame* pFrame, SalEvent nEvent, sal_uInt
}
}
+// When Num Lock is off, the key codes from NumPag come as arrows, PgUp/PgDn, etc.
+static WORD NumPadFromArrows(WORD vk)
+{
+ switch (vk)
+ {
+ case VK_CLEAR:
+ return VK_NUMPAD5;
+ case VK_PRIOR:
+ return VK_NUMPAD9;
+ case VK_NEXT:
+ return VK_NUMPAD3;
+ case VK_END:
+ return VK_NUMPAD1;
+ case VK_HOME:
+ return VK_NUMPAD7;
+ case VK_LEFT:
+ return VK_NUMPAD4;
+ case VK_UP:
+ return VK_NUMPAD8;
+ case VK_RIGHT:
+ return VK_NUMPAD6;
+ case VK_DOWN:
+ return VK_NUMPAD2;
+ case VK_INSERT:
+ return VK_NUMPAD0;
+ default:
+ return vk;
+ }
+}
+
+static bool HandleAltNumPadCode(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
+{
+ struct
+ {
+ bool started = false;
+ //static bool hex = false; // TODO: support HKEY_CURRENT_USER\Control Panel\Input Method\EnableHexNumpad
+ sal_UCS4 ch = 0;
+ bool wait_WM_CHAR = false;
+ void clear()
+ {
+ started = false;
+ ch = 0;
+ wait_WM_CHAR = false;
+ }
+ } static state;
+
+ WORD vk = LOWORD(wParam);
+ WORD keyFlags = HIWORD(lParam);
+
+ switch (nMsg)
+ {
+ case WM_CHAR:
+ if (state.wait_WM_CHAR && MapVirtualKeyW(LOBYTE(keyFlags), MAPVK_VSC_TO_VK) == VK_MENU)
+ {
+ state.clear();
+ // Ignore it - it is synthetized (incorrect, truncated) character from system
+ return true;
+ }
+
+ break;
+
+ case WM_SYSKEYDOWN:
+ if (vk == VK_MENU)
+ {
+ if (!(keyFlags & KF_REPEAT))
+ state.clear();
+ state.started = true;
+ return true;
+ }
+
+ if (!state.started)
+ break;
+
+ if (keyFlags & KF_EXTENDED)
+ break; // NUMPAD numeric keys are *not* considered extended
+
+ vk = NumPadFromArrows(vk);
+ if (vk >= VK_NUMPAD0 && vk <= VK_NUMPAD9)
+ return true;
+
+ break;
+
+ case WM_SYSKEYUP:
+ if (!state.started)
+ break;
+
+ if (keyFlags & KF_EXTENDED)
+ break; // NUMPAD numeric keys are *not* considered extended
+
+ vk = NumPadFromArrows(vk);
+ if (vk >= VK_NUMPAD0 && vk <= VK_NUMPAD9)
+ {
+ state.ch *= 10;
+ state.ch += vk - VK_NUMPAD0;
+ return true;
+ }
+
+ break;
+
+ case WM_KEYUP:
+ if (vk == VK_MENU && state.started && state.ch)
+ {
+ sal_UCS4 ch = state.ch;
+ state.clear();
+ // Let system provide codes for values below 256
+ if (ch >= 256 && rtl::isUnicodeCodePoint(ch))
+ {
+ PostMessageW(hWnd, WM_UNICHAR, ch, 0);
+ state.wait_WM_CHAR = true;
+ }
+ return true;
+ }
+ break;
+ }
+
+ state.clear();
+ return false;
+}
+
static bool ImplHandleKeyMsg( HWND hWnd, UINT nMsg,
WPARAM wParam, LPARAM lParam, LRESULT& rResult )
{
@@ -3531,7 +3650,9 @@ static bool ImplHandleKeyMsg( HWND hWnd, UINT nMsg,
static sal_uInt16 nLastChar = 0;
static ModKeyFlags nLastModKeyCode = ModKeyFlags::NONE;
static bool bWaitForModKeyRelease = false;
- sal_uInt16 nRepeat = LOWORD( lParam )-1;
+ sal_uInt16 nRepeat = LOWORD( lParam );
+ if (nRepeat)
+ --nRepeat;
sal_uInt16 nModCode = 0;
// this key might have been relayed by SysChild and thus
@@ -3544,6 +3665,9 @@ static bool ImplHandleKeyMsg( HWND hWnd, UINT nMsg,
return false;
}
+ if (HandleAltNumPadCode(hWnd, nMsg, wParam, lParam))
+ return true; // no default processing
+
WinSalFrame* pFrame = GetWindowPtr( hWnd );
if ( !pFrame )
return false;