bump product version to 6.3.0.0.beta1
[LibreOffice.git] / extensions / source / scanner / twain32shim.hxx
blobb72df438d59673c61bdc9cbd68829aa6ee9da08d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #ifndef INCLUDED_EXTENSIONS_SOURCE_SCANNER_TWAIN32SHIM_HXX
12 #define INCLUDED_EXTENSIONS_SOURCE_SCANNER_TWAIN32SHIM_HXX
14 #include <prewin.h>
15 #include <postwin.h>
16 #include <exception>
17 #include <string>
18 #include <sstream>
19 #include <iomanip>
21 // Don't use WM_USER
23 // Notifications from shim to parent; wParam = event id
24 #define WM_TWAIN_EVENT (WM_USER + 1)
26 // lParam is HWND
27 #define TWAIN_EVENT_NOTIFYHWND 0
29 // lParam is result (bool indicating success)
30 #define TWAIN_EVENT_REQUESTRESULT 1
32 // lParam is ignored
33 #define TWAIN_EVENT_NONE 10
34 #define TWAIN_EVENT_QUIT 11
35 #define TWAIN_EVENT_SCANNING 12
37 // lParam is HANDLE to shared file mapping valid in context of parent process
38 #define TWAIN_EVENT_XFER 13
40 // Requests from parent to shim; wParam = request id
41 #define WM_TWAIN_REQUEST (WM_USER + 2)
43 #define TWAIN_REQUEST_QUIT 0 // Destroy()
44 #define TWAIN_REQUEST_SELECTSOURCE 1
45 #define TWAIN_REQUEST_INITXFER 2
47 // messages starting from this are not to be used for interprocess communications
48 #define WM_SHIM_INTERNAL (WM_USER + 200)
50 template <typename IntType> std::string Num2Hex(IntType n)
52 std::stringstream sMsg;
53 sMsg << "0x" << std::uppercase << std::setfill('0') << std::setw(sizeof(n) * 2) << std::hex
54 << n;
55 return sMsg.str();
58 void ThrowWin32Error(const char* sFunc, DWORD nWin32Error)
60 std::stringstream sMsg;
61 sMsg << sFunc << " failed with Win32 error code " << Num2Hex(nWin32Error) << "!";
63 throw std::exception(sMsg.str().c_str());
66 void ThrowLastError(const char* sFunc) { ThrowWin32Error(sFunc, GetLastError()); }
68 #endif
70 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */