Skip to content

Commit

Permalink
tdf#114635: reimplement TWAIN-based scan using 32-bit shim on Windows
Browse files Browse the repository at this point in the history
Since TWAIN is only actually available as 32-bit component on Windows,
to use it in a 64-bit program, we need a 32-bit shim program that does
all actual communication with TWAIN subsystem.

This change reimplements TWAIN implementation to be a separate 32-bit
process. Image is transfered from the shim to main program using file
mapping API.

This reverts most of commit 585d980.
64-bit LibreOffice doesn't bundle TWAIN DSM library now. TWAIN DSM
source code is still used for TWAIN headers.

Change-Id: I46f178ad36acd97a9eff156624b99036fcbb83f8
Reviewed-on: https://gerrit.libreoffice.org/65688
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
  • Loading branch information
mikekaganski committed Dec 29, 2018
1 parent c3c2ac6 commit 648f24f
Show file tree
Hide file tree
Showing 20 changed files with 1,095 additions and 1,145 deletions.
2 changes: 1 addition & 1 deletion Repository.mk
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ $(eval $(call gb_Helper_register_executables_for_install,OOO,brand, \
unoinfo \
unopkg \
unopkg_com \
twain32shim \
) \
))

Expand Down Expand Up @@ -957,7 +958,6 @@ $(eval $(call gb_Helper_register_packages_for_install,ooo,\
)) \
sfx2_classification \
$(if $(filter OPENCL,$(BUILD_TYPE)),sc_opencl_runtimetest) \
$(if $(and $(filter WNT,$(OS)), $(filter X86_64,$(CPUNAME))),twain_dsm) \
$(if $(ENABLE_HTMLHELP),\
helpcontent2_html_dynamic \
helpcontent2_html_media \
Expand Down
2 changes: 2 additions & 0 deletions config_host.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export BUILD_TYPE=@BUILD_TYPE@
export BUILD_UNOWINREG=@BUILD_UNOWINREG@
export BUILD_VER_STRING=@BUILD_VER_STRING@
export BUILD_X64=@BUILD_X64@
export BUILD_X86=@BUILD_X86@
export BZIP2_CFLAGS=$(gb_SPACE)@BZIP2_CFLAGS@
export BZIP2_LIBS=$(gb_SPACE)@BZIP2_LIBS@
export CAIRO_CFLAGS=$(gb_SPACE)@CAIRO_CFLAGS@
Expand Down Expand Up @@ -86,6 +87,7 @@ export CUSTOM_BRAND_DIR=@CUSTOM_BRAND_DIR@
export CUSTOM_BRAND_IMAGES=@CUSTOM_BRAND_IMAGES@
export CXX=@CXX@
export CXX_X64_BINARY=@CXX_X64_BINARY@
export CXX_X86_BINARY=@CXX_X86_BINARY@
@x_CXXFLAGS@ export CXXFLAGS=@CXXFLAGS@
export CXXFLAGS_CXX11=@CXXFLAGS_CXX11@
export DATADIR=@DATADIR@
Expand Down
23 changes: 23 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3600,6 +3600,29 @@ if test "$_os" = "WINNT"; then
# These are passed to the environment and then used in gbuild/platform/com_MSC_class.mk
AC_SUBST(CXX_X64_BINARY)
AC_SUBST(LINK_X64_BINARY)

# Check for 32-bit compiler to use to build the 32-bit TWAIN shim
# needed to support TWAIN scan on both 32- and 64-bit systems

BUILD_X86=
CXX_X86_BINARY=

if test "$BITNESS_OVERRIDE" = "64"; then
AC_MSG_CHECKING([for a x86 compiler and libraries for 32-bit binaries required for TWAIN support])
if "$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/HostX86/x86/cl.exe" -? </dev/null >/dev/null 2>&1; then
BUILD_X86=TRUE
CXX_X86_BINARY="$VC_PRODUCT_DIR/Tools/MSVC/$vcbuildnumber/bin/HostX86/x86/cl.exe -arch:SSE"
AC_MSG_RESULT([found])
else
AC_MSG_RESULT([not found])
AC_MSG_WARN([Installation set will not contain 32-bit binaries required for TWAIN support])
fi
else
BUILD_X86=TRUE
CXX_X86_BINARY=$MSVC_CXX
fi
AC_SUBST(BUILD_X86)
AC_SUBST(CXX_X86_BINARY)
fi
AC_SUBST(VCVER)
AC_SUBST(DEVENV)
Expand Down
33 changes: 33 additions & 0 deletions extensions/Executable_twain32shim.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

$(eval $(call gb_Executable_Executable,twain32shim))

$(eval $(call gb_Executable_set_targettype_gui,twain32shim,YES))

$(eval $(call gb_Executable_set_x86,twain32shim,YES))

$(eval $(call gb_Executable_use_externals,twain32shim,\
sane_headers \
))

$(eval $(call gb_Executable_set_include,twain32shim,\
-I$(SRCDIR)/extensions/inc \
$$(INCLUDE) \
))

$(eval $(call gb_Executable_add_exception_objects,twain32shim,\
extensions/source/scanner/twain32shim \
))

$(eval $(call gb_Executable_use_system_win32_libs,twain32shim,\
shell32 \
))

# vim:set noet sw=4 ts=4:
15 changes: 8 additions & 7 deletions extensions/Library_scn.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $(eval $(call gb_Library_Library,scn))

$(eval $(call gb_Library_use_externals,scn,\
boost_headers \
sane_headers \
$(if $(filter-out WNT,$(OS)),sane_headers) \
))

$(eval $(call gb_Library_set_include,scn,\
Expand All @@ -26,15 +26,16 @@ $(eval $(call gb_Library_set_componentfile,scn,extensions/source/scanner/scn))
$(eval $(call gb_Library_use_sdk_api,scn))

$(eval $(call gb_Library_use_libraries,scn,\
svt \
vcl \
tl \
utl \
comphelper \
cppuhelper \
cppu \
sal \
cppuhelper \
i18nlangtag \
sal \
$(if $(filter WNT,$(OS)),salhelper) \
svt \
tl \
utl \
vcl \
))

$(eval $(call gb_Library_add_exception_objects,scn,\
Expand Down
5 changes: 4 additions & 1 deletion extensions/Module_extensions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ ifneq ($(filter-out iOS ANDROID,$(OS)),)
$(eval $(call gb_Module_add_targets,extensions,\
Library_abp \
Library_ldapbe2 \
$(if $(filter WNT,$(OS)),Library_WinUserInfoBe) \
Library_log \
Library_scn \
$(if $(filter WNT,$(OS)), \
Library_WinUserInfoBe \
$(if $(filter TRUE,$(BUILD_X86)),Executable_twain32shim) \
) \
UIConfig_sabpilot \
UIConfig_scanner \
))
Expand Down
Loading

0 comments on commit 648f24f

Please sign in to comment.