diff options
author | Michael Stahl <mstahl@redhat.com> | 2017-06-12 22:25:22 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-06-13 10:41:24 +0200 |
commit | 4ffdb6750fa7d656d249a745f9c6d5ba98353b14 (patch) | |
tree | b76a1b0d910886e9e6519c6fa31d918d253ebc3e | |
parent | 144edb88d29d397604010734f2d6c2e9d7626d1c (diff) |
remove TDE integration (vclplug, address book, config backend)
It has ~no users, can't even be built on modern Linuxes, and it annoys
folks who want to refactor VCL.
Per ESC decision from 2017-06-08, remove --enable-tde and --enable-tdeab.
Change-Id: I51ce4786f29f8fcac2e2bb2a654c41fbfbbd8afd
Reviewed-on: https://gerrit.libreoffice.org/38718
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
87 files changed, 3 insertions, 13720 deletions
diff --git a/Repository.mk b/Repository.mk index 2c2d22e443f6..4854e1e01999 100644 --- a/Repository.mk +++ b/Repository.mk @@ -258,17 +258,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,graphicfilter, \ graphicfilter \ )) -$(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,tde, \ - $(if $(ENABLE_TDE),tdebe1) \ - $(if $(USING_X11), \ - $(if $(ENABLE_TDE),vclplug_tde) \ - ) \ -)) - -$(eval $(call gb_Helper_register_executables_for_install,OOO,tde, \ - $(if $(ENABLE_TDE),tdefilepicker) \ -)) - $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,impress, \ animcore \ PresenterScreen \ @@ -423,8 +412,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \ svxcore \ sw \ syssh \ - $(if $(ENABLE_TDEAB),tdeab1) \ - $(if $(ENABLE_TDEAB),tdeabdrv1) \ textconversiondlgs \ textfd \ tk \ diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk index eb0b3e2c9d40..b821955f21d2 100644 --- a/RepositoryExternal.mk +++ b/RepositoryExternal.mk @@ -2975,28 +2975,6 @@ endef endif # ENABLE_KDE4 -ifeq ($(ENABLE_TDE),TRUE) - -define gb_LinkTarget__use_tde -$(call gb_LinkTarget_add_libs,$(1),\ - $(TDE_LIBS) \ -) - -$(call gb_LinkTarget_set_include,$(1),\ - $$(INCLUDE) \ - $(TDE_CFLAGS) \ -) -endef - -else # ! ENABLE_TDE - -define gb_LinkTarget__use_tde - -endef - -endif # ENABLE_TDE - - # PYTHON # extra python_headers external because pyuno wrapper must not link python ifneq ($(SYSTEM_PYTHON),) diff --git a/bin/distro-install-file-lists b/bin/distro-install-file-lists index 779ad7d6e57f..378f55ce746b 100755 --- a/bin/distro-install-file-lists +++ b/bin/distro-install-file-lists @@ -216,15 +216,6 @@ if test "z$OOO_VENDOR" != "zDebian" ; then cd $FILELISTSDIR - # tde subpackage - test -f $DESTDIR/gid_Module_Optional_Tde && cp $DESTDIR/gid_Module_Optional_Tde tde_list.txt || : - mv_file_between_flists tde_list.txt common_list.txt $INSTALLDIR/program/tdefilepicker - mv_file_between_flists tde_list.txt common_list.txt $INSTALLDIR/program/fps_tdelo.so - mv_file_between_flists tde_list.txt common_list.txt $INSTALLDIR/program/libvclplug_tdel..so - mv_file_between_flists tde_list.txt common_list.txt $INSTALLDIR/program/libtdeab1l..so - mv_file_between_flists tde_list.txt common_list.txt $INSTALLDIR/program/libtdeabdrv1l..so - add_used_directories tde_list.txt common_list.txt - # create kde4 subpackage test -f $DESTDIR/gid_Module_Optional_Kde && cp $DESTDIR/gid_Module_Optional_Kde kde4_list.txt || : mv_file_between_flists kde4_list.txt common_list.txt $INSTALLDIR/program/libvclplug_kde4l..so @@ -404,7 +395,6 @@ else create_package_directory gid_Module_Brand_Prg_Base pkg/libreoffice-base create_package_directory gid_Module_Pyuno pkg/python-uno create_package_directory gid_Module_Optional_Gnome pkg/libreoffice-gnome - create_package_directory gid_Module_Optional_Tde pkg/libreoffice-tde create_package_directory gid_Module_Root_Files_2 pkg/libreoffice-common create_package_directory gid_Module_Root_Files_3 pkg/libreoffice-common @@ -476,7 +466,7 @@ else fi && ( cd pkg/libreoffice-common/$d find -maxdepth 1 \ - -regex '\./\(.*\.so.*\|.*\.bin\|pagein\|tdefilepicker\|msfontextract\|.*\.rdb\|javaldx\|uri-encode\)' \ + -regex '\./\(.*\.so.*\|.*\.bin\|pagein\|msfontextract\|.*\.rdb\|javaldx\|uri-encode\)' \ -exec mv {} $DESTDIR/pkg/libreoffice-core/$d \; ); \ done diff --git a/config_host.mk.in b/config_host.mk.in index da45e1426271..98d3edc06be6 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -168,8 +168,6 @@ export ENABLE_SDREMOTE_BLUETOOTH=@ENABLE_SDREMOTE_BLUETOOTH@ export ENABLE_SILENT_MSI=@ENABLE_SILENT_MSI@ export ENABLE_SYMBOLS=@ENABLE_SYMBOLS@ export ENABLE_SYSTRAY_GTK=@ENABLE_SYSTRAY_GTK@ -export ENABLE_TDE=@ENABLE_TDE@ -export ENABLE_TDEAB=@ENABLE_TDEAB@ export ENABLE_VALGRIND=@ENABLE_VALGRIND@ export ENABLE_VLC=@ENABLE_VLC@ export ENABLE_WERROR=@ENABLE_WERROR@ @@ -562,9 +560,6 @@ export SYSTEM_WPS=@SYSTEM_WPS@ export SYSTEM_ZLIB=@SYSTEM_ZLIB@ export SYSTEM_ZMF=@SYSTEM_ZMF@ export TARFILE_LOCATION=@TARFILE_LOCATION@ -export TDE_CFLAGS=$(gb_SPACE)@TDE_CFLAGS@ -export TDE_LIBS=$(gb_SPACE)@TDE_LIBS@ -export TDE_MOC=$(gb_SPACE)@TDE_MOC@ export TESTINSTALLDIR=@TESTINSTALLDIR@ export THES_SYSTEM_DIR=@THES_SYSTEM_DIR@ export TLS=@TLS@ diff --git a/config_host/config_vclplug.h.in b/config_host/config_vclplug.h.in index 12d90ee704f6..510d0d25229c 100644 --- a/config_host/config_vclplug.h.in +++ b/config_host/config_vclplug.h.in @@ -9,6 +9,5 @@ Settings about which X11 desktops have support enabled. #define ENABLE_GTK 0 #define ENABLE_KDE4 0 -#define ENABLE_TDE 0 #endif diff --git a/configure.ac b/configure.ac index b8496c2f5fb9..d3d1542ba99e 100644 --- a/configure.ac +++ b/configure.ac @@ -640,7 +640,6 @@ solaris*) test_gtk=yes build_gstreamer_1_0=yes build_gstreamer_0_10=yes - test_tde=yes test_freetype=yes _os=SunOS @@ -668,7 +667,6 @@ linux-gnu*|k*bsd*-gnu*) test_gtk=yes build_gstreamer_1_0=yes build_gstreamer_0_10=yes - test_tde=yes test_kde4=yes if test "$enable_fuzzers" != yes; then test_freetype=yes @@ -750,7 +748,6 @@ freebsd*) test_gtk=yes build_gstreamer_1_0=yes build_gstreamer_0_10=yes - test_tde=yes test_kde4=yes test_freetype=yes AC_MSG_CHECKING([the FreeBSD operating system release]) @@ -779,7 +776,6 @@ freebsd*) test_gtk=yes build_gstreamer_1_0=yes build_gstreamer_0_10=yes - test_tde=no test_kde4=yes test_freetype=yes PTHREAD_LIBS="-pthread -lpthread" @@ -795,7 +791,6 @@ aix*) openbsd*) test_gtk=yes - test_tde=yes test_freetype=yes PTHREAD_CFLAGS="-D_THREAD_SAFE" PTHREAD_LIBS="-pthread" @@ -806,7 +801,6 @@ dragonfly*) test_gtk=yes build_gstreamer_1_0=yes build_gstreamer_0_10=yes - test_tde=yes test_kde4=yes test_freetype=yes PTHREAD_LIBS="-pthread" @@ -830,7 +824,6 @@ linux-android*) test_fontconfig=no test_freetype=no test_gtk=no - test_tde=no test_kde4=no test_randr=no test_xrender=no @@ -1263,21 +1256,6 @@ libo_FUZZ_ARG_ENABLE(gio, [Determines whether to use the GIO support.]), ,test "${enable_gio+set}" = set || enable_gio=yes) -AC_ARG_ENABLE(tde, - AS_HELP_STRING([--enable-tde], - [Determines whether to use TQt/TDE vclplug on platforms where TQt and - TDE are available.]), -,) - -AC_ARG_ENABLE(tdeab, - AS_HELP_STRING([--disable-tdeab], - [Disable the TDE address book support.]), -, - if test "$enable_tde" = "yes"; then - enable_tdeab=yes - fi -) - AC_ARG_ENABLE(kde4, AS_HELP_STRING([--enable-kde4], [Determines whether to use Qt4/KDE4 vclplug on platforms where Qt4 and @@ -4619,7 +4597,6 @@ if test "$USING_X11" != TRUE; then test_gtk=no build_gstreamer_1_0=no build_gstreamer_0_10=no - test_tde=no test_kde4=no enable_cairo_canvas=no fi @@ -9787,14 +9764,6 @@ if test "x$enable_gtk" = "xyes"; then fi AC_SUBST(ENABLE_GTK) -ENABLE_TDE="" -if test "x$enable_tde" = "xyes"; then - ENABLE_TDE="TRUE" - AC_DEFINE(ENABLE_TDE) - R="$R tde" -fi -AC_SUBST(ENABLE_TDE) - ENABLE_KDE4="" if test "x$enable_kde4" = "xyes"; then ENABLE_KDE4="TRUE" @@ -10585,7 +10554,7 @@ AC_SUBST(ENABLE_SCRIPTING_JAVASCRIPT) AC_SUBST(SYSTEM_RHINO) AC_SUBST(RHINO_JAR) -# This is only used in KDE3/KDE4/TDE checks to determine if /usr/lib64 +# This is only used in KDE3/KDE4 checks to determine if /usr/lib64 # paths should be added to library search path. So lets put all 64-bit # platforms there. supports_multilib= @@ -10600,135 +10569,6 @@ x86_64 | powerpc64 | powerpc64le | s390x | aarch64 | mips64 | mips64el) esac dnl =================================================================== -dnl Check whether the TQt and TDE libraries are available. -dnl =================================================================== - -TDE_CFLAGS="" -TDE_LIBS="" -if test "$_os" != "OpenBSD"; then - TDE_MOC="moc" -fi -if test "$test_tde" = "yes" -a "$ENABLE_TDE" = "TRUE"; then - dnl Search paths for TQt and TDE - if test -z "$supports_multilib"; then - tqt_incdirs="$QTINC /usr/local/tqt3/include /usr/include/tqt3 /usr/include /usr/X11R6/include/X11/tqt3 /usr/X11R6/include/tqt3 /usr/lib/tqt3/include /usr/lib/tqt3/include /usr/share/tqt3/include /usr/local/include/X11/tqt3 $x_includes" - tqt_libdirs="$QTLIB /usr/local/tqt3/lib /usr/lib/tqt3 /usr/lib /usr/X11R6/lib/X11/tqt3 /usr/X11R6/lib/tqt3 /usr/lib/tqt3/lib /usr/lib/tqt3/lib /usr/share/tqt3/lib /usr/local/lib/tqt3 $x_libraries" - else - tqt_incdirs="$QTINC /usr/local/tqt3/include /usr/include/tqt3 /usr/include /usr/X11R6/include/X11/tqt3 /usr/X11R6/include/tqt3 /usr/lib64/tqt3/include /usr/lib64/tqt3/include /usr/share/tqt3/include /usr/lib/tqt3/include /usr/lib/tqt3/include /usr/local/include/X11/tqt3 $x_includes" - tqt_libdirs="$QTLIB /usr/local/tqt3/lib64 /usr/lib64/tqt3 /usr/lib64 /usr/X11R6/lib64/X11/tqt3 /usr/X11R6/lib64/tqt3 /usr/lib64/tqt3/lib64 /usr/lib64/tqt3/lib64 /usr/share/tqt3/lib64 /usr/local/tqt3/lib /usr/lib/tqt3 /usr/lib /usr/X11R6/lib/X11/tqt3 /usr/X11R6/lib/tqt3 /usr/lib/tqt3/lib /usr/lib/tqt3/lib /usr/share/tqt3/lib /usr/local/lib/tqt3 $x_libraries" - fi - if test -n "$TQTDIR"; then - tqt_incdirs="$TQTDIR/include $tqt_incdirs" - if test -z "$supports_multilib"; then - tqt_libdirs="$TQTDIR/lib $tqt_libdirs" - else - tqt_libdirs="$TQTDIR/lib64 $TQTDIR/lib $tqt_libdirs" - fi - fi - if test -z "$supports_multilib"; then - tde_incdirs="/usr/lib/trinity/include /usr/local/trinity/include /usr/local/include /usr/trinity/include /usr/include/trinity /opt/trinity/include /opt/trinity/include $x_includes" - tde_libdirs="/usr/lib/trinity/lib /usr/local/trinity/lib /usr/trinity/lib /usr/lib/trinity /usr/lib/trinity /usr/X11R6/lib /usr/local/lib /opt/trinity/lib /opt/trinity/lib /usr/X11R6/trinity/lib /usr/lib $x_libraries" - else - tde_incdirs="/usr/lib64/trinity/include /usr/lib/trinity/include /usr/local/trinity/include /usr/local/include /usr/trinity/include /usr/include/trinity /opt/trinity/include /opt/trinity/include $x_includes" - tde_libdirs="/usr/lib64/trinity/lib64 /usr/local/trinity/lib64 /usr/trinity/lib64 /usr/lib64/trinity /usr/lib64/trinity /usr/X11R6/lib64 /usr/local/lib64 /opt/trinity/lib64 /opt/trinity/lib64 /usr/X11R6/trinity/lib64 /usr/lib/trinity/lib /usr/local/trinity/lib /usr/trinity/lib /usr/lib/trinity /usr/lib/trinity /usr/lib /usr/X11R6/lib /usr/local/lib /opt/trinity/lib /opt/trinity/lib /usr/X11R6/trinity/lib /usr/lib64 $x_libraries" - fi - if test -n "$TDEDIR"; then - tde_incdirs="$TDEDIR/include $tde_incdirs" - if test -z "$supports_multilib"; then - tde_libdirs="$TDEDIR/lib $tde_libdirs" - else - tde_libdirs="$TDEDIR/lib64 $TDEDIR/lib $tde_libdirs" - fi - fi - - dnl What to test - tqt_test_include="ntqstyle.h" - tde_test_include="kapp.h" - - if test "$_os" != "OpenBSD"; then - tqt_test_library="libtqt-mt.so" - tde_test_library="libDCOP.so" - else - tqt_test_library="libtqt-mt.so*" - tde_test_library="libDCOP.so*" - fi - - dnl Check for TQt headers - AC_MSG_CHECKING([for TQt headers]) - tqt_incdir="no" - for tde_check in $tqt_incdirs; do - if test -r "$tde_check/$tqt_test_include"; then - tqt_incdir="$tde_check" - break - fi - done - AC_MSG_RESULT([$tqt_incdir]) - if test "x$tqt_incdir" = "xno"; then - AC_MSG_ERROR([TQt headers not found. Please specify the root of -your TQt installation by exporting TQTDIR before running "configure".]) - fi - - dnl Check for TQt libraries - AC_MSG_CHECKING([for TQt libraries]) - tqt_libdir="no" - for tqt_check in $tqt_libdirs; do - if test -r "`ls $tqt_check/$tqt_test_library 2>/dev/null | head -1`"; then - tqt_libdir="$tqt_check" - break - fi - done - AC_MSG_RESULT([$tqt_libdir]) - if test "x$tqt_libdir" = "xno"; then - AC_MSG_ERROR([TQt libraries not found. Please specify the root of -your TQt installation by exporting TQTDIR before running "configure".]) - fi - - dnl Check for Meta Object Compiler - AC_PATH_PROG( MOC, moc, no, [`dirname $tqt_libdir`/bin:$TQTDIR/bin:$PATH] ) - if test "$MOC" = "no"; then - AC_MSG_ERROR([TQt Meta Object Compiler not found. Please specify -the root of your TQt installation by exporting TQTDIR before running "configure".]) - fi - - dnl Check for TDE headers - AC_MSG_CHECKING([for TDE headers]) - tde_incdir="no" - for tde_check in $tde_incdirs; do - if test -r "$tde_check/$tde_test_include"; then - tde_incdir="$tde_check" - break - fi - done - AC_MSG_RESULT([$tde_incdir]) - if test "x$tde_incdir" = "xno"; then - AC_MSG_ERROR([TDE headers not found. Please specify the root of -your TDE installation by exporting TDEDIR before running "configure".]) - fi - - dnl Check for TDE libraries - AC_MSG_CHECKING([for TDE libraries]) - tde_libdir="no" - for tde_check in $tde_libdirs; do - if test -r "`ls $tde_check/$tde_test_library 2>/dev/null | head -1`"; then - tde_libdir="$tde_check" - break - fi - done - AC_MSG_RESULT([$tde_libdir]) - if test "x$tde_libdir" = "xno"; then - AC_MSG_ERROR([TDE libraries not found. Please specify the root of -your TDE installation by exporting TDEDIR before running "configure".]) - fi - - dnl Set the variables - TDE_CFLAGS="-I$tqt_incdir -I$tde_incdir -I/usr/include/tqt -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT" - TDE_LIBS="-L$tde_libdir -L$tqt_libdir -ltdeio -ltdeui -ltdecore -ltqt -ltqt-mt" -fi -AC_SUBST(TDE_CFLAGS) -AC_SUBST(TDE_LIBS) -AC_SUBST(TDE_MOC) - -dnl =================================================================== dnl KDE4 Integration dnl =================================================================== @@ -11030,34 +10870,6 @@ AC_SUBST(GOBJECT_CFLAGS) AC_SUBST(GOBJECT_LIBS) dnl =================================================================== -dnl Test whether to include TDE AB support -dnl =================================================================== -AC_MSG_CHECKING([whether to enable TDE address book support]) -if test "$enable_tdeab" = "yes" -a "$enable_tde" = "yes"; then - AC_MSG_RESULT([yes]) - AC_LANG_PUSH([C++]) - save_CXXFLAGS=$CXXFLAGS - CXXFLAGS="$CXXFLAGS $TDE_CFLAGS" - AC_MSG_CHECKING([whether TDE is at least R14.0]) - AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include <tdeversion.h> - -int main(int argc, char **argv) { - if (TDE_VERSION_MAJOR >= 14) return 0; - else return 1; -} - ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([TDE version too old or too recent, please use another version of TDE or disable TDE address book support])], - [AC_MSG_ERROR([TDE support not tested with cross compilation])]) - CXXFLAGS=$save_CXXFLAGS - AC_LANG_POP([C++]) - ENABLE_TDEAB=TRUE -else - AC_MSG_RESULT([no]) - ENABLE_TDEAB= -fi -AC_SUBST(ENABLE_TDEAB) - -dnl =================================================================== dnl Test which themes to include dnl =================================================================== AC_MSG_CHECKING([which themes to include]) diff --git a/connectivity/Configuration_tdeab.mk b/connectivity/Configuration_tdeab.mk deleted file mode 100644 index 63162c33d9f5..000000000000 --- a/connectivity/Configuration_tdeab.mk +++ /dev/null @@ -1,20 +0,0 @@ -# -*- 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_Configuration_Configuration,driver_tdeab)) - -$(eval $(call gb_Configuration_add_spool_modules,driver_tdeab,connectivity/registry/tdeab,\ - org/openoffice/Office/DataAccess/Drivers-tdeab.xcu \ -)) - -$(eval $(call gb_Configuration_add_localized_datas,driver_tdeab,connectivity/registry/tdeab,\ - org/openoffice/Office/DataAccess/Drivers.xcu \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_tdeab1.mk b/connectivity/Library_tdeab1.mk deleted file mode 100644 index 513d095323cf..000000000000 --- a/connectivity/Library_tdeab1.mk +++ /dev/null @@ -1,42 +0,0 @@ -# -*- 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_Library_Library,tdeab1)) - -$(eval $(call gb_Library_use_externals,tdeab1,\ - boost_headers \ - tde \ -)) - -$(eval $(call gb_Library_set_componentfile,tdeab1,connectivity/source/drivers/kab/tdeab1)) - -$(eval $(call gb_Library_set_include,tdeab1,\ - -I$(SRCDIR)/connectivity/source/inc \ - $$(INCLUDE) \ -)) - -$(eval $(call gb_Library_use_sdk_api,tdeab1)) - -$(eval $(call gb_Library_use_libraries,tdeab1,\ - comphelper \ - cppu \ - cppuhelper \ - dbtools \ - sal \ - salhelper \ - tl \ -)) - -$(eval $(call gb_Library_add_exception_objects,tdeab1,\ - connectivity/source/drivers/kab/KDriver \ - connectivity/source/drivers/kab/KServices \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_tdeabdrv1.mk b/connectivity/Library_tdeabdrv1.mk deleted file mode 100644 index 6bcf1c42a8a1..000000000000 --- a/connectivity/Library_tdeabdrv1.mk +++ /dev/null @@ -1,56 +0,0 @@ -# -*- 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_Library_Library,tdeabdrv1)) - -$(eval $(call gb_Library_set_include,tdeabdrv1,\ - -I$(SRCDIR)/connectivity/source/inc \ - $$(INCLUDE) \ - -I$(WORKDIR)/YaccTarget/connectivity/source/parse \ -)) - -$(eval $(call gb_Library_use_sdk_api,tdeabdrv1)) - -$(eval $(call gb_Library_use_externals,tdeabdrv1,\ - boost_headers \ - tde \ -)) - -$(eval $(call gb_Library_add_libs,tdeabdrv1,\ - -ltdeabc \ -)) - -$(eval $(call gb_Library_use_libraries,tdeabdrv1,\ - cppu \ - cppuhelper \ - sal \ - salhelper \ - dbtools \ - comphelper \ -)) - -$(eval $(call gb_Library_add_exception_objects,tdeabdrv1,\ - connectivity/source/drivers/kab/KColumns \ - connectivity/source/drivers/kab/KTable \ - connectivity/source/drivers/kab/KTables \ - connectivity/source/drivers/kab/KCatalog \ - connectivity/source/drivers/kab/KResultSet \ - connectivity/source/drivers/kab/KStatement \ - connectivity/source/drivers/kab/KPreparedStatement \ - connectivity/source/drivers/kab/KDatabaseMetaData \ - connectivity/source/drivers/kab/KConnection \ - connectivity/source/drivers/kab/KResultSetMetaData \ - connectivity/source/drivers/kab/kcondition \ - connectivity/source/drivers/kab/korder \ - connectivity/source/drivers/kab/kfields \ - connectivity/source/drivers/kab/KDEInit \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/connectivity/Module_connectivity.mk b/connectivity/Module_connectivity.mk index 2c5904b489aa..efb057ff4ba4 100644 --- a/connectivity/Module_connectivity.mk +++ b/connectivity/Module_connectivity.mk @@ -49,14 +49,6 @@ endif ifneq ($(OS),WNT) -ifeq ($(ENABLE_TDEAB),TRUE) -$(eval $(call gb_Module_add_targets,connectivity,\ - Configuration_tdeab \ - Library_tdeab1 \ - Library_tdeabdrv1 \ -)) -endif - ifeq ($(OS),MACOSX) $(eval $(call gb_Module_add_targets,connectivity,\ Configuration_macab \ diff --git a/connectivity/registry/tdeab/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/tdeab/org/openoffice/Office/DataAccess/Drivers.xcu deleted file mode 100644 index 8ef69433ccec..000000000000 --- a/connectivity/registry/tdeab/org/openoffice/Office/DataAccess/Drivers.xcu +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> -<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema"> - <node oor:name="Installed" install:module="tdeab"> - <node oor:name="sdbc:address:tdeab" oor:op="replace"> - <prop oor:name="Driver"> - <value>com.sun.star.comp.sdbc.tdeab.Driver</value> - </prop> - <prop oor:name="DriverTypeDisplayName" oor:type="xs:string"> - <value xml:lang="en-US">TDE Address Book</value> - </prop> - <node oor:name="Features"> - <node oor:name="EscapeDateTime" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - </node> - </node> - </node> -</oor:component-data> diff --git a/connectivity/source/drivers/kab/KCatalog.cxx b/connectivity/source/drivers/kab/KCatalog.cxx deleted file mode 100644 index 9d7926af2a8c..000000000000 --- a/connectivity/source/drivers/kab/KCatalog.cxx +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "KCatalog.hxx" -#include "KConnection.hxx" -#include "KTables.hxx" - -using namespace connectivity::kab; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; -using namespace ::cppu; - - -KabCatalog::KabCatalog(KabConnection* _pCon) - : connectivity::sdbcx::OCatalog(_pCon), - m_pConnection(_pCon) -{ -} - -void KabCatalog::refreshTables() -{ - TStringVector aVector; - Sequence< OUString > aTypes { "%" }; - Reference< XResultSet > xResult = m_xMetaData->getTables( - Any(), "%", "%", aTypes); - - if (xResult.is()) - { - Reference< XRow > xRow(xResult,UNO_QUERY); - OUString aName; - - while (xResult->next()) - { - // aName = xRow->getString(2); - // aName += sDot; - aName = xRow->getString(3); - aVector.push_back(aName); - } - } - if (m_pTables) - m_pTables->reFill(aVector); - else - m_pTables = new KabTables(m_xMetaData,*this,m_aMutex,aVector); -} - -void KabCatalog::refreshViews() -{ -} - -void KabCatalog::refreshGroups() -{ -} - -void KabCatalog::refreshUsers() -{ -} - - -// XTablesSupplier -Reference< XNameAccess > SAL_CALL KabCatalog::getTables( ) -{ - ::osl::MutexGuard aGuard(m_aMutex); - checkDisposed(rBHelper.bDisposed); - - try - { - if (!m_pTables) - refreshTables(); - } - catch( const RuntimeException& ) - { - // allowed to leave this method - throw; - } - catch( const Exception& ) - { - // allowed - } - - return m_pTables; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KCatalog.hxx b/connectivity/source/drivers/kab/KCatalog.hxx deleted file mode 100644 index d369e916e0ed..000000000000 --- a/connectivity/source/drivers/kab/KCatalog.hxx +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCATALOG_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCATALOG_HXX - -#include <connectivity/sdbcx/VCatalog.hxx> - -namespace connectivity -{ - namespace kab - { - class KabConnection; - - class KabCatalog : public connectivity::sdbcx::OCatalog - { - KabConnection* m_pConnection; // used to get the metadata - - public: - explicit KabCatalog(KabConnection* _pCon); - - KabConnection* getConnection() const { return m_pConnection; } - - // implementation of the pure virtual methods - virtual void refreshTables() override; - virtual void refreshViews() override; - virtual void refreshGroups() override; - virtual void refreshUsers() override; - - // XTablesSupplier - virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTables( - ) override; - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCATALOG_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KColumns.cxx b/connectivity/source/drivers/kab/KColumns.cxx deleted file mode 100644 index c94726d55001..000000000000 --- a/connectivity/source/drivers/kab/KColumns.cxx +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "KColumns.hxx" -#include "KTable.hxx" -#include "KTables.hxx" -#include "KCatalog.hxx" -#include <connectivity/sdbcx/VColumn.hxx> - -using namespace connectivity::kab; -using namespace connectivity::sdbcx; -using namespace connectivity; -using namespace ::comphelper; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; - - -sdbcx::ObjectType KabColumns::createObject(const OUString& _rName) -{ - const Any aCatalog; - const OUString sCatalogName; - const OUString sSchemaName(m_pTable->getSchema()); - const OUString sTableName(m_pTable->getTableName()); - Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns( - aCatalog, sSchemaName, sTableName, _rName); - - sdbcx::ObjectType xRet = nullptr; - if (xResult.is()) - { - Reference< XRow > xRow(xResult,UNO_QUERY); - - while (xResult->next()) - { - if (xRow->getString(4) == _rName) - { - OColumn* pRet = new OColumn( - _rName, - xRow->getString(6), - xRow->getString(13), - xRow->getString(12), - xRow->getInt(11), - xRow->getInt(7), - xRow->getInt(9), - xRow->getInt(5), - false, - false, - false, - true, - sCatalogName, - sSchemaName, - sTableName); - xRet = pRet; - break; - } - } - } - - return xRet; -} - -void KabColumns::impl_refresh() -{ - m_pTable->refreshColumns(); -} - -KabColumns::KabColumns( KabTable* _pTable, - ::osl::Mutex& _rMutex, - const TStringVector &_rVector) - : sdbcx::OCollection(*_pTable, true, _rMutex, _rVector), - m_pTable(_pTable) -{ -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KColumns.hxx b/connectivity/source/drivers/kab/KColumns.hxx deleted file mode 100644 index 887048347d42..000000000000 --- a/connectivity/source/drivers/kab/KColumns.hxx +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCOLUMNS_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCOLUMNS_HXX - -#include "KTable.hxx" -#include <connectivity/sdbcx/VCollection.hxx> - -namespace connectivity -{ - namespace kab - { - class KabColumns : public sdbcx::OCollection - { - protected: - KabTable* m_pTable; - - virtual sdbcx::ObjectType createObject(const OUString& _rName) override; - virtual void impl_refresh() override; - - public: - KabColumns( KabTable* _pTable, - ::osl::Mutex& _rMutex, - const TStringVector &_rVector); - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCOLUMNS_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KConnection.cxx b/connectivity/source/drivers/kab/KConnection.cxx deleted file mode 100644 index 0d54a1428872..000000000000 --- a/connectivity/source/drivers/kab/KConnection.cxx +++ /dev/null @@ -1,319 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "KConnection.hxx" -#include "KDatabaseMetaData.hxx" -#include "KStatement.hxx" -#include "KPreparedStatement.hxx" -#include "KCatalog.hxx" -#include <com/sun/star/sdbc/ColumnValue.hpp> -#include <com/sun/star/sdbc/TransactionIsolation.hpp> -#include <shell/kde_headers.h> - -using namespace connectivity::kab; -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::beans; -using namespace com::sun::star::sdbc; -using namespace com::sun::star::sdbcx; - -IMPLEMENT_SERVICE_INFO(KabConnection, "com.sun.star.sdbc.drivers.KabConnection", "com.sun.star.sdbc.Connection") - -KabConnection::KabConnection( - css::uno::Reference<css::uno::XComponentContext> const & componentContext, - css::uno::Reference<css::sdbc::XDriver> const & driver) - : OMetaConnection_BASE(m_aMutex), - OSubComponent<KabConnection, KabConnection_BASE>(driver, this), - m_xMetaData(nullptr), - m_pAddressBook(nullptr), - m_xComponentContext(componentContext) -{} - -KabConnection::~KabConnection() -{ - if (!isClosed()) - close(); -} - -void SAL_CALL KabConnection::release() throw() -{ - release_ChildImpl(); -} - -//TODO: is doing this after the ctor, and the manual ref counting really -// necessary? -void KabConnection::construct() -{ - osl_atomic_increment( &m_refCount ); - - // create a KDE address book object - m_pAddressBook = KABC::StdAddressBook::self(); - KABC::StdAddressBook::setAutomaticSave(false); - - osl_atomic_decrement( &m_refCount ); -} -// XServiceInfo - -Reference< XStatement > SAL_CALL KabConnection::createStatement( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabConnection_BASE::rBHelper.bDisposed); - - // create a statement - // the statement can only be executed once - Reference< XStatement > xReturn = new KabStatement(this); - m_aStatements.push_back(WeakReferenceHelper(xReturn)); - return xReturn; -} - -Reference< XPreparedStatement > SAL_CALL KabConnection::prepareStatement( const OUString& _sSql ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabConnection_BASE::rBHelper.bDisposed); - - // create a statement - // the statement can only be executed more than once - Reference< XPreparedStatement > xReturn = new KabPreparedStatement(this, _sSql); - m_aStatements.push_back(WeakReferenceHelper(xReturn)); - return xReturn; -} - -Reference< XPreparedStatement > SAL_CALL KabConnection::prepareCall( const OUString& ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabConnection_BASE::rBHelper.bDisposed); - - // not implemented yet :-) a task to do - return nullptr; -} - -OUString SAL_CALL KabConnection::nativeSQL( const OUString& _sSql ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - // when you need to transform SQL92 to you driver specific you can do it here - - return _sSql; -} - -void SAL_CALL KabConnection::setAutoCommit( sal_Bool ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabConnection_BASE::rBHelper.bDisposed); - // here you have to set your commit mode please have a look at the jdbc documentation to get a clear explanation -} - -sal_Bool SAL_CALL KabConnection::getAutoCommit( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabConnection_BASE::rBHelper.bDisposed); - // you have to distinguish which if you are in autocommit mode or not - // at normal case true should be fine here - - return true; -} - -void SAL_CALL KabConnection::commit( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabConnection_BASE::rBHelper.bDisposed); - - // when you database does support transactions you should commit here -} - -void SAL_CALL KabConnection::rollback( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabConnection_BASE::rBHelper.bDisposed); - - // same as commit but for the other case -} - -sal_Bool SAL_CALL KabConnection::isClosed( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - // just simple -> we are closed when we are disposed, that means someone called dispose(); (XComponent) - return KabConnection_BASE::rBHelper.bDisposed; -} - -Reference< XDatabaseMetaData > SAL_CALL KabConnection::getMetaData( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabConnection_BASE::rBHelper.bDisposed); - - // here we have to create the class with biggest interface - // The answer is 42 :-) - Reference< XDatabaseMetaData > xMetaData = m_xMetaData; - if (!xMetaData.is()) - { - xMetaData = new KabDatabaseMetaData(this); // need the connection because it can return it - m_xMetaData = xMetaData; - } - - return xMetaData; -} - -void SAL_CALL KabConnection::setReadOnly( sal_Bool ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabConnection_BASE::rBHelper.bDisposed); - - // set you connection to readonly -} - -sal_Bool SAL_CALL KabConnection::isReadOnly( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabConnection_BASE::rBHelper.bDisposed); - - // return if your connection to readonly - return false; -} - -void SAL_CALL KabConnection::setCatalog( const OUString& ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabConnection_BASE::rBHelper.bDisposed); - - // if your database doesn't work with catalogs you go to next method otherwise you know what to do -} - -OUString SAL_CALL KabConnection::getCatalog( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabConnection_BASE::rBHelper.bDisposed); - - - // return your current catalog - return OUString(); -} - -void SAL_CALL KabConnection::setTransactionIsolation( sal_Int32 ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabConnection_BASE::rBHelper.bDisposed); - - // set your isolation level - // please have a look at @see com.sun.star.sdbc.TransactionIsolation -} - -sal_Int32 SAL_CALL KabConnection::getTransactionIsolation( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabConnection_BASE::rBHelper.bDisposed); - - - // please have a look at @see com.sun.star.sdbc.TransactionIsolation - return TransactionIsolation::NONE; -} - -Reference< css::container::XNameAccess > SAL_CALL KabConnection::getTypeMap( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabConnection_BASE::rBHelper.bDisposed); - - // if your driver has special database types you can return it here - - return nullptr; -} - -void SAL_CALL KabConnection::setTypeMap( const Reference< css::container::XNameAccess >& ) -{ - // the other way around -} - -// XCloseable -void SAL_CALL KabConnection::close( ) -{ - { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabConnection_BASE::rBHelper.bDisposed); - } - dispose(); -} - -// XWarningsSupplier -Any SAL_CALL KabConnection::getWarnings( ) -{ - // when you collected some warnings -> return it - return Any(); -} - -void SAL_CALL KabConnection::clearWarnings( ) -{ - // you should clear your collected warnings here -} - -void KabConnection::disposing() -{ - // we noticed that we should be destroyed in near future so we have to dispose our statements - ::osl::MutexGuard aGuard(m_aMutex); - - for (OWeakRefArray::iterator i = m_aStatements.begin(); m_aStatements.end() != i; ++i) - { - Reference< XComponent > xComp(i->get(), UNO_QUERY); - if (xComp.is()) - xComp->dispose(); - } - m_aStatements.clear(); - - if (m_pAddressBook != nullptr) - { - KABC::StdAddressBook::close(); - m_pAddressBook = nullptr; - } - - m_xMetaData = css::uno::WeakReference< css::sdbc::XDatabaseMetaData>(); - - dispose_ChildImpl(); - KabConnection_BASE::disposing(); -} - -Reference< XTablesSupplier > SAL_CALL KabConnection::createCatalog() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - Reference< XTablesSupplier > xTab = m_xCatalog; - if (!m_xCatalog.is()) - { - KabCatalog *pCat = new KabCatalog(this); - xTab = pCat; - m_xCatalog = xTab; - } - return xTab; -} - -::KABC::AddressBook* KabConnection::getAddressBook() const -{ - return m_pAddressBook; -} - -extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL -createKabConnection( - css::uno::Reference<css::uno::XComponentContext> const & componentContext, - css::uno::Reference<css::sdbc::XDriver> const & driver) -{ - rtl::Reference<KabConnection> con( - new KabConnection(componentContext, driver)); - con->construct(); - return cppu::acquire(con.get()); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KConnection.hxx b/connectivity/source/drivers/kab/KConnection.hxx deleted file mode 100644 index 0958cc1d39cb..000000000000 --- a/connectivity/source/drivers/kab/KConnection.hxx +++ /dev/null @@ -1,138 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCONNECTION_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCONNECTION_HXX - -#include <map> -#include <connectivity/OSubComponent.hxx> -#include <connectivity/CommonTools.hxx> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/sdbc/SQLWarning.hpp> -#include <com/sun/star/sdbc/XWarningsSupplier.hpp> -#include <com/sun/star/sdbc/XConnection.hpp> -#include <com/sun/star/sdbcx/XTablesSupplier.hpp> -#include <cppuhelper/basemutex.hxx> -#include <cppuhelper/compbase.hxx> -#include <shell/kde_headers.h> - -namespace KABC -{ - class StdAddressBook; - class AddressBook; -} -namespace com { namespace sun { namespace star { namespace sdbc { - class XDriver; -} } } } - -namespace connectivity -{ - namespace kab - { - - typedef ::cppu::WeakComponentImplHelper<css::sdbc::XConnection, - css::sdbc::XWarningsSupplier, - css::lang::XServiceInfo - > OMetaConnection_BASE; - - typedef OMetaConnection_BASE KabConnection_BASE; // implements basics and text encoding - typedef std::vector< css::uno::WeakReferenceHelper > OWeakRefArray; - - class KabConnection : public cppu::BaseMutex, - public KabConnection_BASE, - public OSubComponent<KabConnection, KabConnection_BASE> - { - friend class OSubComponent<KabConnection, KabConnection_BASE>; - - protected: - - // Data attributes - - css::uno::WeakReference< css::sdbc::XDatabaseMetaData > m_xMetaData; - - OWeakRefArray m_aStatements; // vector containing a list of all the Statement objects - // for this Connection - - ::KABC::StdAddressBook* m_pAddressBook; // the address book - css::uno::Reference<css::uno::XComponentContext> m_xComponentContext; - css::uno::Reference< css::sdbcx::XTablesSupplier> - m_xCatalog; // needed for the SQL interpreter - - public: - void construct(); - - KabConnection( - css::uno::Reference<css::uno::XComponentContext> const & - componentContext, - css::uno::Reference<css::sdbc::XDriver> const & driver); - virtual ~KabConnection() override; - - void closeAllStatements (); - - // OComponentHelper - virtual void SAL_CALL disposing() override; - - // XInterface - virtual void SAL_CALL release() throw() override; - - // XServiceInfo - DECLARE_SERVICE_INFO(); - - // XConnection - virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement( ) override; - virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const OUString& sql ) override; - virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall( const OUString& sql ) override; - virtual OUString SAL_CALL nativeSQL( const OUString& sql ) override; - virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) override; - virtual sal_Bool SAL_CALL getAutoCommit( ) override; - virtual void SAL_CALL commit( ) override; - virtual void SAL_CALL rollback( ) override; - virtual sal_Bool SAL_CALL isClosed( ) override; - virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) override; - virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) override; - virtual sal_Bool SAL_CALL isReadOnly( ) override; - virtual void SAL_CALL setCatalog( const OUString& catalog ) override; - virtual OUString SAL_CALL getCatalog( ) override; - virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) override; - virtual sal_Int32 SAL_CALL getTransactionIsolation( ) override; - virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTypeMap( ) override; - virtual void SAL_CALL setTypeMap( const css::uno::Reference< css::container::XNameAccess >& typeMap ) override; - - // XCloseable - virtual void SAL_CALL close( ) override; - - // XWarningsSupplier - virtual css::uno::Any SAL_CALL getWarnings( ) override; - virtual void SAL_CALL clearWarnings( ) override; - - // needed for the SQL interpreter - css::uno::Reference< css::sdbcx::XTablesSupplier > SAL_CALL createCatalog(); - - css::uno::Reference<css::uno::XComponentContext> - getComponentContext() const - { return m_xComponentContext; } - - ::KABC::AddressBook* getAddressBook() const; - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCONNECTION_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KDEInit.cxx b/connectivity/source/drivers/kab/KDEInit.cxx deleted file mode 100644 index 2d31339b6545..000000000000 --- a/connectivity/source/drivers/kab/KDEInit.cxx +++ /dev/null @@ -1,149 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "KDEInit.h" -#include <osl/diagnose.h> -#include <osl/process.h> - -#include <shell/kde_headers.h> - -namespace connectivity -{ - namespace kab - { - - // = KDEInit - - class KDEInit - { - private: - /// KDE application if we own it - static KApplication* s_pKApplication; - static bool s_bDidInsertCatalogue; - - public: - static void Init(); - static void Shutdown(); - }; - - - KApplication* KDEInit::s_pKApplication = nullptr; - bool KDEInit::s_bDidInsertCatalogue = false; - - - void KDEInit::Init() - { - // TODO: All this is not thread-safe - - // we create a KDE application only if it is not already done - if (KApplication::kApplication() == nullptr) - { - OSL_ENSURE(s_pKApplication == nullptr, "KDEInit::Init: inconsistency in the application pointers!"); - - char *kabargs[1] = {const_cast<char*>("libkab1")}; - KCmdLineArgs::init(1, kabargs, "KAddressBook", *kabargs, "Address Book driver", KAB_DRIVER_VERSION); - - s_pKApplication = new KApplication(false, false); - } - - /* FIXME-BCP47: what slumbering dogs may we wake up here? */ - // set language - rtl_Locale *pProcessLocale; - osl_getProcessLocale(&pProcessLocale); - // sal_Unicode and QChar are (currently) both 16 bits characters - QString aLanguage( - reinterpret_cast<QChar *>(pProcessLocale->Language->buffer), - (int) pProcessLocale->Language->length); - KGlobal::locale()->setLanguage(aLanguage); - - // load KDE address book's localized messages - KGlobal::locale()->insertCatalogue("kaddressbook"); - s_bDidInsertCatalogue = true; - } - - - void KDEInit::Shutdown() - { - if ( s_bDidInsertCatalogue ) - // this guard is necessary, since KDE 3.3 seems to crash if we remove a catalogue - // which we did not previously insert - KGlobal::locale()->removeCatalogue("kaddressbook"); - - if ( s_pKApplication != nullptr ) - { - delete s_pKApplication; - s_pKApplication = nullptr; - } - } - } -} - - -namespace -{ - double normalizeVersion( unsigned int major, unsigned int minor ) - { - return major + 1.0 * minor / 1000; - } -} - - -extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL initKApplication() -{ - ::connectivity::kab::KDEInit::Init(); -} - - -extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL shutdownKApplication() -{ - ::connectivity::kab::KDEInit::Shutdown(); -} - -/** checks whether the KDE version on the system we're running at is supported - by the driver - - Has to be called before any other code from this library, in particular, - it has to be called before initKApplication() - - If this function returns <code>0</code>, then no other code from this library - has to be called, else the results are unpredictable. - - @return - <ul><li><code>0</code> if the KDE version is not supported</li> - <li>a negative value if the version is too old</li> - <li>a positive value if the version is too new to know whether it works with this driver</li> - </ul> - - #i60062# -*/ -extern "C" SAL_DLLPUBLIC_EXPORT int SAL_CALL matchKDEVersion() -{ - double nMinVersion = normalizeVersion( MIN_KDE_VERSION_MAJOR, MIN_KDE_VERSION_MINOR ); - double nCurVersion = normalizeVersion( ::KDE::versionMajor(), ::KDE::versionMinor() ); - double nMaxVersion = normalizeVersion( MAX_KDE_VERSION_MAJOR, MAX_KDE_VERSION_MINOR ); - - if ( nCurVersion < nMinVersion ) - return -1; - if ( nCurVersion > nMaxVersion ) - return 1; - - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KDEInit.h b/connectivity/source/drivers/kab/KDEInit.h deleted file mode 100644 index d14447b34306..000000000000 --- a/connectivity/source/drivers/kab/KDEInit.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KDEINIT_H -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KDEINIT_H - -// the address book driver's version -#define KAB_DRIVER_VERSION "0.2" -#define KAB_DRIVER_VERSION_MAJOR 0 -#define KAB_DRIVER_VERSION_MINOR 2 - -#include <config_vclplug.h> - -#if ENABLE_TDE - -// the minimum TDE version which is required at runtime -#define MIN_KDE_VERSION_MAJOR 14 -#define MIN_KDE_VERSION_MINOR 0 - -#define MAX_KDE_VERSION_MAJOR 255 -#define MAX_KDE_VERSION_MINOR 255 - -#else // ENABLE_TDE - -// the minimum KDE version which is required at runtime -#define MIN_KDE_VERSION_MAJOR 3 -#define MIN_KDE_VERSION_MINOR 2 - -#define MAX_KDE_VERSION_MAJOR 3 -#define MAX_KDE_VERSION_MINOR 6 - -#endif // ENABLE_TDE - - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KDEINIT_H - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KDatabaseMetaData.cxx b/connectivity/source/drivers/kab/KDatabaseMetaData.cxx deleted file mode 100644 index 70bfea861bb4..000000000000 --- a/connectivity/source/drivers/kab/KDatabaseMetaData.cxx +++ /dev/null @@ -1,1069 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "KDatabaseMetaData.hxx" -#include "kfields.hxx" -#include "KDEInit.h" -#include <shell/kde_headers.h> -#include "FDatabaseMetaDataResultSet.hxx" -#include "OTypeInfo.hxx" -#include <com/sun/star/sdbc/ColumnValue.hpp> -#include <com/sun/star/sdbc/ResultSetType.hpp> -#include <com/sun/star/sdbc/TransactionIsolation.hpp> - -using namespace connectivity::kab; -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::beans; -using namespace com::sun::star::sdbc; - -KabDatabaseMetaData::KabDatabaseMetaData(KabConnection* _pCon) - : m_xConnection(_pCon), - m_bUseCatalog(true) -{ - OSL_ENSURE(_pCon,"KabDatabaseMetaData::KabDatabaseMetaData: No connection set!"); - - osl_atomic_increment( &m_refCount ); - m_bUseCatalog = !(usesLocalFiles() || usesLocalFilePerTable()); - osl_atomic_decrement( &m_refCount ); -} - -KabDatabaseMetaData::~KabDatabaseMetaData() -{ -} - -const OUString & KabDatabaseMetaData::getAddressBookTableName() -{ - static const OUString aAddressBookTableName("Address Book"); - return aAddressBookTableName; -} - -OUString SAL_CALL KabDatabaseMetaData::getCatalogSeparator( ) -{ - OUString aVal; - if (m_bUseCatalog) - { // do some special here for you database - } - - return aVal; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxBinaryLiteralLength( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxRowSize( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxCatalogNameLength( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxCharLiteralLength( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxColumnNameLength( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxColumnsInIndex( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxCursorNameLength( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxConnections( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxColumnsInTable( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxStatementLength( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxTableNameLength( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxTablesInSelect( ) -{ - // MaxTablesInSelect describes how many tables can participate in the FROM part of a given SELECT statement, - // currently, the resultset/statement implementations can cope with one table only - sal_Int32 nValue = 1; - return nValue; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::storesLowerCaseIdentifiers( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::storesMixedCaseQuotedIdentifiers( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::storesMixedCaseIdentifiers( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::storesUpperCaseIdentifiers( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsAlterTableWithAddColumn( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsAlterTableWithDropColumn( ) -{ - return false; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxIndexLength( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsNonNullableColumns( ) -{ - return false; -} - -OUString SAL_CALL KabDatabaseMetaData::getCatalogTerm( ) -{ - OUString aVal; - if (m_bUseCatalog) - { - } - return aVal; -} - -OUString SAL_CALL KabDatabaseMetaData::getIdentifierQuoteString( ) -{ - // normally this is " - OUString aVal("\""); - return aVal; -} - -OUString SAL_CALL KabDatabaseMetaData::getExtraNameCharacters( ) -{ - OUString aVal; - return aVal; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsDifferentTableCorrelationNames( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::isCatalogAtStart( ) -{ - bool bValue = false; - if (m_bUseCatalog) - { - } - return bValue; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::dataDefinitionIgnoredInTransactions( ) -{ - return true; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::dataDefinitionCausesTransactionCommit( ) -{ - return true; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsDataManipulationTransactionsOnly( ) -{ - return true; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) -{ - return true; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsPositionedDelete( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsPositionedUpdate( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsOpenStatementsAcrossRollback( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsOpenStatementsAcrossCommit( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsOpenCursorsAcrossCommit( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsOpenCursorsAcrossRollback( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsSchemasInDataManipulation( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsANSI92FullSQL( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsANSI92EntryLevelSQL( ) -{ - return true; // should be supported at least -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsIntegrityEnhancementFacility( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsSchemasInIndexDefinitions( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsSchemasInTableDefinitions( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsCatalogsInTableDefinitions( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsCatalogsInIndexDefinitions( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsCatalogsInDataManipulation( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsOuterJoins( ) -{ - return false; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxStatements( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxProcedureNameLength( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxSchemaNameLength( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsTransactions( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::allProceduresAreCallable( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsStoredProcedures( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsSelectForUpdate( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::allTablesAreSelectable( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::isReadOnly( ) -{ - // for the moment, we have read-only addresses, but this might change in the future - return true; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::usesLocalFiles( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::usesLocalFilePerTable( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsTypeConversion( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::nullPlusNonNullIsNull( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsColumnAliasing( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsTableCorrelationNames( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsConvert( sal_Int32, sal_Int32 ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsExpressionsInOrderBy( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsGroupBy( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsGroupByBeyondSelect( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsGroupByUnrelated( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsMultipleTransactions( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsMultipleResultSets( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsLikeEscapeClause( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsOrderByUnrelated( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsUnion( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsUnionAll( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsMixedCaseIdentifiers( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsMixedCaseQuotedIdentifiers( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::nullsAreSortedAtEnd( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::nullsAreSortedAtStart( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::nullsAreSortedHigh( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::nullsAreSortedLow( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsSchemasInProcedureCalls( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsCatalogsInProcedureCalls( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsCorrelatedSubqueries( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsSubqueriesInComparisons( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsSubqueriesInExists( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsSubqueriesInIns( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsSubqueriesInQuantifieds( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsANSI92IntermediateSQL( ) -{ - return false; -} - -OUString SAL_CALL KabDatabaseMetaData::getURL( ) -{ - // if someday we support more than the default address book, - // this method should return the URL which was used to create it - OUString aValue( "sdbc:address:kab:" ); - return aValue; -} - -OUString SAL_CALL KabDatabaseMetaData::getUserName( ) -{ - OUString aValue; - return aValue; -} - -OUString SAL_CALL KabDatabaseMetaData::getDriverName( ) -{ - OUString aValue( "kab" ); - return aValue; -} - -OUString SAL_CALL KabDatabaseMetaData::getDriverVersion() -{ - OUString aValue(KAB_DRIVER_VERSION); - return aValue; -} - -OUString SAL_CALL KabDatabaseMetaData::getDatabaseProductVersion( ) -{ - OUString aValue; - return aValue; -} - -OUString SAL_CALL KabDatabaseMetaData::getDatabaseProductName( ) -{ - OUString aValue; - return aValue; -} - -OUString SAL_CALL KabDatabaseMetaData::getProcedureTerm( ) -{ - OUString aValue; - return aValue; -} - -OUString SAL_CALL KabDatabaseMetaData::getSchemaTerm( ) -{ - OUString aValue; - return aValue; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getDriverMajorVersion( ) -{ - return KAB_DRIVER_VERSION_MAJOR; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getDefaultTransactionIsolation( ) -{ - return TransactionIsolation::NONE; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getDriverMinorVersion( ) -{ - return KAB_DRIVER_VERSION_MINOR; -} - -OUString SAL_CALL KabDatabaseMetaData::getSQLKeywords( ) -{ - OUString aValue; - return aValue; -} - -OUString SAL_CALL KabDatabaseMetaData::getSearchStringEscape( ) -{ - OUString aValue; - return aValue; -} - -OUString SAL_CALL KabDatabaseMetaData::getStringFunctions( ) -{ - return OUString(); -} - -OUString SAL_CALL KabDatabaseMetaData::getTimeDateFunctions( ) -{ - return OUString(); -} - -OUString SAL_CALL KabDatabaseMetaData::getSystemFunctions( ) -{ - return OUString(); -} - -OUString SAL_CALL KabDatabaseMetaData::getNumericFunctions( ) -{ - return OUString(); -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsExtendedSQLGrammar( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsCoreSQLGrammar( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsMinimumSQLGrammar( ) -{ - return true; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsFullOuterJoins( ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsLimitedOuterJoins( ) -{ - return false; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxColumnsInGroupBy( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxColumnsInOrderBy( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxColumnsInSelect( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxUserNameLength( ) -{ - sal_Int32 nValue = 0; // 0 means no limit - return nValue; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsResultSetType( sal_Int32 setType ) -{ - switch (setType) - { - case ResultSetType::FORWARD_ONLY: - case ResultSetType::SCROLL_INSENSITIVE: - return true; - } - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 ) -{ - switch (setType) - { - case ResultSetType::FORWARD_ONLY: - case ResultSetType::SCROLL_INSENSITIVE: - return true; - } - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::ownUpdatesAreVisible( sal_Int32 ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::ownDeletesAreVisible( sal_Int32 ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::ownInsertsAreVisible( sal_Int32 ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::othersUpdatesAreVisible( sal_Int32 ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::othersDeletesAreVisible( sal_Int32 ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::othersInsertsAreVisible( sal_Int32 ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::updatesAreDetected( sal_Int32 ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::deletesAreDetected( sal_Int32 ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::insertsAreDetected( sal_Int32 ) -{ - return false; -} - -sal_Bool SAL_CALL KabDatabaseMetaData::supportsBatchUpdates( ) -{ - return false; -} - -Reference< XConnection > SAL_CALL KabDatabaseMetaData::getConnection( ) -{ - return m_xConnection.get(); -} - -Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getTableTypes( ) -{ - ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes); - Reference< XResultSet > xRef = pResult; - - static ODatabaseMetaDataResultSet::ORows aRows; - - if (aRows.empty()) - { - ODatabaseMetaDataResultSet::ORow aRow(2); - aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[1] = new ORowSetValueDecorator(OUString("TABLE")); - aRows.push_back(aRow); - } - pResult->setRows(aRows); - return xRef; -} - -Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getTypeInfo( ) -{ - ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo); - Reference< XResultSet > xRef = pResult; - - static ODatabaseMetaDataResultSet::ORows aRows; - if (aRows.empty()) - { - ODatabaseMetaDataResultSet::ORow aRow(19); - - aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[1] = new ORowSetValueDecorator(OUString("CHAR")); - aRow[2] = new ORowSetValueDecorator(DataType::CHAR); - aRow[3] = new ORowSetValueDecorator((sal_Int32) 254); - aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); - aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); - aRow[6] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[7] = new ORowSetValueDecorator((sal_Int32) ColumnValue::NULLABLE); - aRow[8] = ODatabaseMetaDataResultSet::get1Value(); - aRow[9] = new ORowSetValueDecorator((sal_Int32) ColumnSearch::CHAR); - aRow[10] = ODatabaseMetaDataResultSet::get1Value(); - aRow[11] = ODatabaseMetaDataResultSet::get0Value(); - aRow[12] = ODatabaseMetaDataResultSet::get0Value(); - aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[14] = ODatabaseMetaDataResultSet::get0Value(); - aRow[15] = ODatabaseMetaDataResultSet::get0Value(); - aRow[16] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[17] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[18] = new ORowSetValueDecorator((sal_Int32) 10); - aRows.push_back(aRow); -// Much more types might appear in KDE address books -// To be completed - } - pResult->setRows(aRows); - return xRef; -} - -Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getCatalogs( ) -{ - return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCatalogs ); -} - -Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getSchemas( ) -{ - return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eSchemas ); -} - -Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getColumnPrivileges( - const Any&, const OUString&, const OUString&, - const OUString& ) -{ - return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumnPrivileges ); -} - -Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getColumns( - const Any&, - const OUString&, - const OUString& tableNamePattern, - const OUString& columnNamePattern) -{ - ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns); - Reference< XResultSet > xRef = pResult; - - ODatabaseMetaDataResultSet::ORows aRows; - - if (match(tableNamePattern, getAddressBookTableName(), '\0')) - { - ODatabaseMetaDataResultSet::ORow aRow(19); - - aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[1] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[2] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[3] = new ORowSetValueDecorator(getAddressBookTableName()); - aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[9] = ODatabaseMetaDataResultSet::get0Value(); - aRow[10] = new ORowSetValueDecorator((sal_Int32) 10); - aRow[11] = ODatabaseMetaDataResultSet::get1Value(); - aRow[12] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[14] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[15] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[16] = new ORowSetValueDecorator((sal_Int32) 254); - aRow[18] = new ORowSetValueDecorator(OUString("YES")); - - sal_Int32 nPosition = 1; - QString aQtName; - OUString sName; - - aQtName = ::KABC::Addressee::revisionLabel(); - sName = reinterpret_cast<const sal_Unicode *>(aQtName.ucs2()); - if (match(columnNamePattern, sName, '\0')) - { - aRow[4] = new ORowSetValueDecorator(sName); - aRow[5] = new ORowSetValueDecorator(DataType::TIMESTAMP); - aRow[6] = new ORowSetValueDecorator(OUString("TIMESTAMP")); - aRow[17] = new ORowSetValueDecorator(nPosition++); - aRows.push_back(aRow); - } - - ::KABC::Field::List aFields = ::KABC::Field::allFields(); - ::KABC::Field::List::const_iterator aField; - - for ( aField = aFields.begin(); - aField != aFields.end(); - ++aField, ++nPosition) - { - aQtName = (*aField)->label(); - sName = reinterpret_cast<const sal_Unicode *>(aQtName.ucs2()); - if (match(columnNamePattern, sName, '\0')) - { - aRow[4] = new ORowSetValueDecorator(sName); - aRow[5] = new ORowSetValueDecorator(DataType::CHAR); - aRow[6] = new ORowSetValueDecorator(OUString("CHAR")); - aRow[7] = new ORowSetValueDecorator((sal_Int32) 256); -// Might be VARCHAR and not CHAR[256]... - aRow[17] = new ORowSetValueDecorator(nPosition); - aRows.push_back(aRow); - } - } - } - pResult->setRows(aRows); - return xRef; -} - -Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getTables( - const Any&, - const OUString&, - const OUString&, - const Sequence< OUString >& types) -{ - ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTables); - Reference< XResultSet > xRef = pResult; - - // check whether we have tables in the requested types - // for the moment, we answer only the "TABLE" table type - // when no types are given at all, we return all the tables - static const OUString aTable("TABLE"); - bool bTableFound = false; - const OUString* p = types.getConstArray(), - * pEnd = p + types.getLength(); - - if (p == pEnd) - { - bTableFound = true; - } - else while (p < pEnd) - { - if (match(*p, aTable, '\0')) - { - bTableFound = true; - break; - } - p++; - } - if (!bTableFound) - return xRef; - - static ODatabaseMetaDataResultSet::ORows aRows; - - if (aRows.empty()) - { - ODatabaseMetaDataResultSet::ORow aRow(6); - - aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[1] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[2] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[3] = new ORowSetValueDecorator(getAddressBookTableName()); - aRow[4] = new ORowSetValueDecorator(aTable); - aRow[5] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRows.push_back(aRow); - } - pResult->setRows(aRows); - return xRef; -} - -Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getProcedureColumns( - const Any&, const OUString&, - const OUString&, const OUString& ) -{ - return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedureColumns ); -} - -Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getProcedures( - const Any&, const OUString&, - const OUString& ) -{ - return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedures ); -} - -Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getVersionColumns( - const Any&, const OUString&, const OUString& table ) -{ - ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eVersionColumns); - - Reference< XResultSet > xRef = pResult; - - ODatabaseMetaDataResultSet::ORows aRows; - - if (table == getAddressBookTableName()) - { - ODatabaseMetaDataResultSet::ORow aRow( 9 ); - QString aQtName = ::KABC::Addressee::revisionLabel(); - OUString sName = reinterpret_cast<const sal_Unicode *>(aQtName.ucs2()); - - aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[1] = ODatabaseMetaDataResultSet::getEmptyValue(); - - aRow[2] = new ORowSetValueDecorator(sName); - aRow[3] = new ORowSetValueDecorator(DataType::TIMESTAMP); - aRow[4] = new ORowSetValueDecorator(OUString("TIMESTAMP")); - - aRow[5] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[6] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[7] = ODatabaseMetaDataResultSet::getEmptyValue(); - aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue(); - - aRows.push_back(aRow); - } - pResult->setRows(aRows); - return xRef; -} - -Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getExportedKeys( - const Any&, const OUString&, const OUString& ) -{ - return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eExportedKeys ); -} - -Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getImportedKeys( - const Any&, const OUString&, const OUString& ) -{ - return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eImportedKeys ); -} - -Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getPrimaryKeys( - const Any&, const OUString&, const OUString& ) -{ - return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::ePrimaryKeys ); -} - -Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getIndexInfo( - const Any&, const OUString&, const OUString&, - sal_Bool, sal_Bool ) -{ - return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eIndexInfo ); -} - -Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getBestRowIdentifier( - const Any&, const OUString&, const OUString&, sal_Int32, - sal_Bool ) -{ - return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eBestRowIdentifier ); -} - -Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getTablePrivileges( - const Any&, const OUString&, const OUString& ) -{ - return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges ); -} - -Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getCrossReference( - const Any&, const OUString&, - const OUString&, const Any&, - const OUString&, const OUString& ) -{ - return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCrossReference ); -} - -Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getUDTs( const Any&, const OUString&, const OUString&, const Sequence< sal_Int32 >& ) -{ - OSL_FAIL("Not implemented yet!"); - throw SQLException(); -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KDatabaseMetaData.hxx b/connectivity/source/drivers/kab/KDatabaseMetaData.hxx deleted file mode 100644 index ac896c87d582..000000000000 --- a/connectivity/source/drivers/kab/KDatabaseMetaData.hxx +++ /dev/null @@ -1,206 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KDATABASEMETADATA_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KDATABASEMETADATA_HXX - -#include "KConnection.hxx" -#include <com/sun/star/sdbc/XConnection.hpp> -#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> -#include <cppuhelper/implbase.hxx> - -namespace connectivity -{ - namespace kab - { - - //************ Class: KabDatabaseMetaData - - - typedef ::cppu::WeakImplHelper< css::sdbc::XDatabaseMetaData> KabDatabaseMetaData_BASE; - - class KabDatabaseMetaData : public KabDatabaseMetaData_BASE - { - css::uno::Reference< css::sdbc::XConnection > m_xConnection; - bool m_bUseCatalog; - - public: - - explicit KabDatabaseMetaData(KabConnection* _pCon); - static const OUString & getAddressBookTableName(); - virtual ~KabDatabaseMetaData() override; - - // this interface is really BIG - // XDatabaseMetaData - virtual sal_Bool SAL_CALL allProceduresAreCallable( ) override; - virtual sal_Bool SAL_CALL allTablesAreSelectable( ) override; - virtual OUString SAL_CALL getURL( ) override; - virtual OUString SAL_CALL getUserName( ) override; - virtual sal_Bool SAL_CALL isReadOnly( ) override; - virtual sal_Bool SAL_CALL nullsAreSortedHigh( ) override; - virtual sal_Bool SAL_CALL nullsAreSortedLow( ) override; - virtual sal_Bool SAL_CALL nullsAreSortedAtStart( ) override; - virtual sal_Bool SAL_CALL nullsAreSortedAtEnd( ) override; - virtual OUString SAL_CALL getDatabaseProductName( ) override; - virtual OUString SAL_CALL getDatabaseProductVersion( ) override; - virtual OUString SAL_CALL getDriverName( ) override; - virtual OUString SAL_CALL getDriverVersion( ) override; - virtual sal_Int32 SAL_CALL getDriverMajorVersion( ) override; - virtual sal_Int32 SAL_CALL getDriverMinorVersion( ) override; - virtual sal_Bool SAL_CALL usesLocalFiles( ) override; - virtual sal_Bool SAL_CALL usesLocalFilePerTable( ) override; - virtual sal_Bool SAL_CALL supportsMixedCaseIdentifiers( ) override; - virtual sal_Bool SAL_CALL storesUpperCaseIdentifiers( ) override; - virtual sal_Bool SAL_CALL storesLowerCaseIdentifiers( ) override; - virtual sal_Bool SAL_CALL storesMixedCaseIdentifiers( ) override; - virtual sal_Bool SAL_CALL supportsMixedCaseQuotedIdentifiers( ) override; - virtual sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers( ) override; - virtual sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers( ) override; - virtual sal_Bool SAL_CALL storesMixedCaseQuotedIdentifiers( ) override; - virtual OUString SAL_CALL getIdentifierQuoteString( ) override; - virtual OUString SAL_CALL getSQLKeywords( ) override; - virtual OUString SAL_CALL getNumericFunctions( ) override; - virtual OUString SAL_CALL getStringFunctions( ) override; - virtual OUString SAL_CALL getSystemFunctions( ) override; - virtual OUString SAL_CALL getTimeDateFunctions( ) override; - virtual OUString SAL_CALL getSearchStringEscape( ) override; - virtual OUString SAL_CALL getExtraNameCharacters( ) override; - virtual sal_Bool SAL_CALL supportsAlterTableWithAddColumn( ) override; - virtual sal_Bool SAL_CALL supportsAlterTableWithDropColumn( ) override; - virtual sal_Bool SAL_CALL supportsColumnAliasing( ) override; - virtual sal_Bool SAL_CALL nullPlusNonNullIsNull( ) override; - virtual sal_Bool SAL_CALL supportsTypeConversion( ) override; - virtual sal_Bool SAL_CALL supportsConvert( sal_Int32 fromType, sal_Int32 toType ) override; - virtual sal_Bool SAL_CALL supportsTableCorrelationNames( ) override; - virtual sal_Bool SAL_CALL supportsDifferentTableCorrelationNames( ) override; - virtual sal_Bool SAL_CALL supportsExpressionsInOrderBy( ) override; - virtual sal_Bool SAL_CALL supportsOrderByUnrelated( ) override; - virtual sal_Bool SAL_CALL supportsGroupBy( ) override; - virtual sal_Bool SAL_CALL supportsGroupByUnrelated( ) override; - virtual sal_Bool SAL_CALL supportsGroupByBeyondSelect( ) override; - virtual sal_Bool SAL_CALL supportsLikeEscapeClause( ) override; - virtual sal_Bool SAL_CALL supportsMultipleResultSets( ) override; - virtual sal_Bool SAL_CALL supportsMultipleTransactions( ) override; - virtual sal_Bool SAL_CALL supportsNonNullableColumns( ) override; - virtual sal_Bool SAL_CALL supportsMinimumSQLGrammar( ) override; - virtual sal_Bool SAL_CALL supportsCoreSQLGrammar( ) override; - virtual sal_Bool SAL_CALL supportsExtendedSQLGrammar( ) override; - virtual sal_Bool SAL_CALL supportsANSI92EntryLevelSQL( ) override; - virtual sal_Bool SAL_CALL supportsANSI92IntermediateSQL( ) override; - virtual sal_Bool SAL_CALL supportsANSI92FullSQL( ) override; - virtual sal_Bool SAL_CALL supportsIntegrityEnhancementFacility( ) override; - virtual sal_Bool SAL_CALL supportsOuterJoins( ) override; - virtual sal_Bool SAL_CALL supportsFullOuterJoins( ) override; - virtual sal_Bool SAL_CALL supportsLimitedOuterJoins( ) override; - virtual OUString SAL_CALL getSchemaTerm( ) override; - virtual OUString SAL_CALL getProcedureTerm( ) override; - virtual OUString SAL_CALL getCatalogTerm( ) override; - virtual sal_Bool SAL_CALL isCatalogAtStart( ) override; - virtual OUString SAL_CALL getCatalogSeparator( ) override; - virtual sal_Bool SAL_CALL supportsSchemasInDataManipulation( ) override; - virtual sal_Bool SAL_CALL supportsSchemasInProcedureCalls( ) override; - virtual sal_Bool SAL_CALL supportsSchemasInTableDefinitions( ) override; - virtual sal_Bool SAL_CALL supportsSchemasInIndexDefinitions( ) override; - virtual sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions( ) override; - virtual sal_Bool SAL_CALL supportsCatalogsInDataManipulation( ) override; - virtual sal_Bool SAL_CALL supportsCatalogsInProcedureCalls( ) override; - virtual sal_Bool SAL_CALL supportsCatalogsInTableDefinitions( ) override; - virtual sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions( ) override; - virtual sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions( ) override; - virtual sal_Bool SAL_CALL supportsPositionedDelete( ) override; - virtual sal_Bool SAL_CALL supportsPositionedUpdate( ) override; - virtual sal_Bool SAL_CALL supportsSelectForUpdate( ) override; - virtual sal_Bool SAL_CALL supportsStoredProcedures( ) override; - virtual sal_Bool SAL_CALL supportsSubqueriesInComparisons( ) override; - virtual sal_Bool SAL_CALL supportsSubqueriesInExists( ) override; - virtual sal_Bool SAL_CALL supportsSubqueriesInIns( ) override; - virtual sal_Bool SAL_CALL supportsSubqueriesInQuantifieds( ) override; - virtual sal_Bool SAL_CALL supportsCorrelatedSubqueries( ) override; - virtual sal_Bool SAL_CALL supportsUnion( ) override; - virtual sal_Bool SAL_CALL supportsUnionAll( ) override; - virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit( ) override; - virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback( ) override; - virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit( ) override; - virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback( ) override; - virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) override; - virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) override; - virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) override; - virtual sal_Int32 SAL_CALL getMaxColumnsInGroupBy( ) override; - virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) override; - virtual sal_Int32 SAL_CALL getMaxColumnsInOrderBy( ) override; - virtual sal_Int32 SAL_CALL getMaxColumnsInSelect( ) override; - virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) override; - virtual sal_Int32 SAL_CALL getMaxConnections( ) override; - virtual sal_Int32 SAL_CALL getMaxCursorNameLength( ) override; - virtual sal_Int32 SAL_CALL getMaxIndexLength( ) override; - virtual sal_Int32 SAL_CALL getMaxSchemaNameLength( ) override; - virtual sal_Int32 SAL_CALL getMaxProcedureNameLength( ) override; - virtual sal_Int32 SAL_CALL getMaxCatalogNameLength( ) override; - virtual sal_Int32 SAL_CALL getMaxRowSize( ) override; - virtual sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs( ) override; - virtual sal_Int32 SAL_CALL getMaxStatementLength( ) override; - virtual sal_Int32 SAL_CALL getMaxStatements( ) override; - virtual sal_Int32 SAL_CALL getMaxTableNameLength( ) override; - virtual sal_Int32 SAL_CALL getMaxTablesInSelect( ) override; - virtual sal_Int32 SAL_CALL getMaxUserNameLength( ) override; - virtual sal_Int32 SAL_CALL getDefaultTransactionIsolation( ) override; - virtual sal_Bool SAL_CALL supportsTransactions( ) override; - virtual sal_Bool SAL_CALL supportsTransactionIsolationLevel( sal_Int32 level ) override; - virtual sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions( ) override; - virtual sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly( ) override; - virtual sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit( ) override; - virtual sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions( ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getProcedures( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& procedureNamePattern ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getProcedureColumns( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& procedureNamePattern, const OUString& columnNamePattern ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getTables( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern, const css::uno::Sequence< OUString >& types ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getSchemas( ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getCatalogs( ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getTableTypes( ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getColumns( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern, const OUString& columnNamePattern ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getColumnPrivileges( const css::uno::Any& catalog, const OUString& schema, const OUString& table, const OUString& columnNamePattern ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getTablePrivileges( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getBestRowIdentifier( const css::uno::Any& catalog, const OUString& schema, const OUString& table, sal_Int32 scope, sal_Bool nullable ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getVersionColumns( const css::uno::Any& catalog, const OUString& schema, const OUString& table ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getPrimaryKeys( const css::uno::Any& catalog, const OUString& schema, const OUString& table ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getImportedKeys( const css::uno::Any& catalog, const OUString& schema, const OUString& table ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getExportedKeys( const css::uno::Any& catalog, const OUString& schema, const OUString& table ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getCrossReference( const css::uno::Any& primaryCatalog, const OUString& primarySchema, const OUString& primaryTable, const css::uno::Any& foreignCatalog, const OUString& foreignSchema, const OUString& foreignTable ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getTypeInfo( ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getIndexInfo( const css::uno::Any& catalog, const OUString& schema, const OUString& table, sal_Bool unique, sal_Bool approximate ) override; - virtual sal_Bool SAL_CALL supportsResultSetType( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) override; - virtual sal_Bool SAL_CALL ownUpdatesAreVisible( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL ownDeletesAreVisible( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL ownInsertsAreVisible( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL othersUpdatesAreVisible( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL othersDeletesAreVisible( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL othersInsertsAreVisible( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL updatesAreDetected( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL deletesAreDetected( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL insertsAreDetected( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL supportsBatchUpdates( ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getUDTs( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& typeNamePattern, const css::uno::Sequence< sal_Int32 >& types ) override; - virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( ) override; - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KDATABASEMETADATA_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KDriver.cxx b/connectivity/source/drivers/kab/KDriver.cxx deleted file mode 100644 index af99f446221f..000000000000 --- a/connectivity/source/drivers/kab/KDriver.cxx +++ /dev/null @@ -1,463 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <sal/config.h> - -#include <cassert> - -#include "KDriver.hxx" -#include "KDEInit.h" -#include <rtl/strbuf.hxx> - -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/configuration/theDefaultProvider.hpp> -#include <com/sun/star/sdb/SQLContext.hpp> -#include <com/sun/star/lang/NullPointerException.hpp> -#include <com/sun/star/frame/Desktop.hpp> -#include <comphelper/processfactory.hxx> -#include <cppuhelper/supportsservice.hxx> -#include <rtl/ustrbuf.hxx> -#include <tools/diagnose_ex.h> -#include <tools/solar.h> -#include "resource/kab_res.hrc" -#include "resource/sharedresources.hxx" - -#if ENABLE_TDE - -#define KAB_SERVICE_NAME "tdeab" - -#else // ENABLE_TDE - -#define KAB_SERVICE_NAME "kab" - -#endif // ENABLE_TDE - -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::beans; -using namespace com::sun::star::sdbc; -using namespace com::sun::star::sdb; -using namespace com::sun::star::frame; -using namespace connectivity::kab; - -namespace { - -/** throws a generic SQL exception with SQLState S1000 and error code 0 - */ -void throwGenericSQLException( const OUString& _rMessage ) -{ - SQLException aError; - aError.Message = _rMessage; - aError.SQLState = "S1000"; - aError.ErrorCode = 0; - throw aError; -} - -/** throws an SQLException saying than no KDE installation was found - */ -void throwNoKdeException() -{ - ::connectivity::SharedResources aResources; - const OUString sError( aResources.getResourceString( - STR_NO_KDE_INST - ) ); - throwGenericSQLException( sError ); -} - -/** throws an SQLException saying that the found KDE version is too old - */ -void throwKdeTooOldException() -{ - ::connectivity::SharedResources aResources; - const OUString sError( aResources.getResourceStringWithSubstitution( - STR_KDE_VERSION_TOO_OLD, - "$major$",OUString::number(MIN_KDE_VERSION_MAJOR), - "$minor$",OUString::number(MIN_KDE_VERSION_MINOR) - ) ); - throwGenericSQLException( sError ); -} - -/** throws an SQLException saying that the found KDE version is too new - */ -void throwKdeTooNewException() -{ - ::connectivity::SharedResources aResources; - - SQLException aError; - aError.Message = aResources.getResourceStringWithSubstitution( - STR_KDE_VERSION_TOO_NEW, - "$major$",OUString::number(MIN_KDE_VERSION_MAJOR), - "$minor$",OUString::number(MIN_KDE_VERSION_MINOR) - ); - aError.SQLState = "S1000"; - aError.ErrorCode = 0; - - SQLContext aDetails; - OUStringBuffer aMessage; - aMessage.append( aResources.getResourceString(STR_KDE_VERSION_TOO_NEW_WORK_AROUND) ); - - aMessage.append( "Sub disableKDEMaxVersionCheck\n" ); - aMessage.append( " BasicLibraries.LoadLibrary( \"Tools\" )\n" ); - - aMessage.append( " Dim configNode as Object\n" ); - aMessage.append( " configNode = GetRegistryKeyContent( \"" ); - aMessage.append( KabDriver::impl_getConfigurationSettingsPath() ); - aMessage.append( "\", true )\n" ); - - aMessage.append( " configNode.DisableKDEMaximumVersionCheck = TRUE\n" ); - aMessage.append( " configNode.commitChanges\n" ); - aMessage.append( "End Sub\n" ); - - aDetails.Message = aMessage.makeStringAndClear(); - - aError.NextException <<= aDetails; - - throw aError; -} - -} - -// = KabImplModule - - -KabImplModule::KabImplModule( const Reference< XComponentContext >& _rxContext ) - :m_xContext(_rxContext) - ,m_bAttemptedLoadModule(false) - ,m_bAttemptedInitialize(false) - ,m_hConnectorModule(nullptr) - ,m_pConnectionFactoryFunc(nullptr) - ,m_pApplicationInitFunc(nullptr) - ,m_pApplicationShutdownFunc(nullptr) - ,m_pKDEVersionCheckFunc(nullptr) -{ - if ( !m_xContext.is() ) - throw NullPointerException(); -} - - -bool KabImplModule::isKDEPresent() -{ - if ( !impl_loadModule() ) - return false; - - return true; -} - - -KabImplModule::KDEVersionType KabImplModule::matchKDEVersion() -{ - OSL_PRECOND( m_pKDEVersionCheckFunc, "KabImplModule::matchKDEVersion: module not loaded!" ); - - int nVersionInfo = (*m_pKDEVersionCheckFunc)(); - if ( nVersionInfo < 0 ) - return eTooOld; - if ( nVersionInfo > 0 ) - return eToNew; - return eSupported; -} - - -namespace -{ - template< typename FUNCTION > - void lcl_getFunctionFromModuleOrUnload( oslModule& _rModule, const sal_Char* _pAsciiSymbolName, FUNCTION& _rFunction ) - { - _rFunction = nullptr; - if ( _rModule ) - { - - const OUString sSymbolName = OUString::createFromAscii( _pAsciiSymbolName ); - _rFunction = reinterpret_cast<FUNCTION>( osl_getSymbol( _rModule, sSymbolName.pData ) ); - - if ( !_rFunction ) - { // did not find the symbol - OStringBuffer aBuf; - aBuf.append( "lcl_getFunctionFromModuleOrUnload: could not find the symbol " ); - aBuf.append( _pAsciiSymbolName ); - OSL_FAIL( aBuf.makeStringAndClear().getStr() ); - osl_unloadModule( _rModule ); - _rModule = nullptr; - } - } - } -} - - -extern "C" { void SAL_CALL thisModule() {} } - -bool KabImplModule::impl_loadModule() -{ - if ( m_bAttemptedLoadModule ) - return ( m_hConnectorModule != nullptr ); - m_bAttemptedLoadModule = true; - - OSL_ENSURE( !m_hConnectorModule && !m_pConnectionFactoryFunc && !m_pApplicationInitFunc && !m_pApplicationShutdownFunc && !m_pKDEVersionCheckFunc, - "KabImplModule::impl_loadModule: inconsistence: inconsistency (never attempted load before, but some values already set)!"); - - const OUString sModuleName( SVLIBRARY( KAB_SERVICE_NAME "drv1" )); - m_hConnectorModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, SAL_LOADMODULE_NOW ); // LAZY! #i61335# - OSL_ENSURE( m_hConnectorModule, "KabImplModule::impl_loadModule: could not load the implementation library!" ); - if ( !m_hConnectorModule ) - return false; - - lcl_getFunctionFromModuleOrUnload( m_hConnectorModule, "createKabConnection", m_pConnectionFactoryFunc ); - lcl_getFunctionFromModuleOrUnload( m_hConnectorModule, "initKApplication", m_pApplicationInitFunc ); - lcl_getFunctionFromModuleOrUnload( m_hConnectorModule, "shutdownKApplication", m_pApplicationShutdownFunc ); - lcl_getFunctionFromModuleOrUnload( m_hConnectorModule, "matchKDEVersion", m_pKDEVersionCheckFunc ); - - if ( !m_hConnectorModule ) - // one of the symbols did not exist - throw RuntimeException(); - - return true; -} - - -void KabImplModule::impl_unloadModule() -{ - OSL_PRECOND( m_hConnectorModule != nullptr, "KabImplModule::impl_unloadModule: no module!" ); - - osl_unloadModule( m_hConnectorModule ); - m_hConnectorModule = nullptr; - - m_pConnectionFactoryFunc = nullptr; - m_pApplicationInitFunc = nullptr; - m_pApplicationShutdownFunc = nullptr; - m_pKDEVersionCheckFunc = nullptr; - - m_bAttemptedLoadModule = false; -} - - -void KabImplModule::init() -{ - if ( !impl_loadModule() ) - throwNoKdeException(); - - // if we're not running on a supported version, throw - KabImplModule::KDEVersionType eKDEVersion = matchKDEVersion(); - - if ( eKDEVersion == eTooOld ) - throwKdeTooOldException(); - - if ( ( eKDEVersion == eToNew ) && !impl_doAllowNewKDEVersion() ) - throwKdeTooNewException(); - - if ( !m_bAttemptedInitialize ) - { - m_bAttemptedInitialize = true; - (*m_pApplicationInitFunc)(); - } -} - - -bool KabImplModule::impl_doAllowNewKDEVersion() -{ - try - { - Reference< XMultiServiceFactory > xConfigProvider( - css::configuration::theDefaultProvider::get( m_xContext ) ); - Sequence< Any > aCreationArgs(1); - aCreationArgs[0] <<= PropertyValue( "nodepath", 0, - makeAny( KabDriver::impl_getConfigurationSettingsPath() ), - PropertyState_DIRECT_VALUE ); - Reference< XPropertySet > xSettings( xConfigProvider->createInstanceWithArguments( - "com.sun.star.configuration.ConfigurationAccess", - aCreationArgs ), - UNO_QUERY_THROW ); - - bool bDisableCheck = false; - xSettings->getPropertyValue("DisableKDEMaximumVersionCheck") >>= bDisableCheck; - - return bDisableCheck; - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return false; -} - - -css::uno::Reference<css::sdbc::XConnection> KabImplModule::createConnection( - KabDriver * driver) const -{ - assert(m_pConnectionFactoryFunc != nullptr); - return css::uno::Reference<css::sdbc::XConnection>( - (*m_pConnectionFactoryFunc)(m_xContext, driver), - css::uno::UNO_QUERY_THROW); -} - - -void KabImplModule::shutdown() -{ - if ( !m_hConnectorModule ) - return; - - (*m_pApplicationShutdownFunc)(); - m_bAttemptedInitialize = false; - - impl_unloadModule(); -} - - -// = KabDriver - -KabDriver::KabDriver( - const Reference< css::uno::XComponentContext >& _rxContext) - : KDriver_BASE(m_aMutex), - m_xContext(_rxContext), - m_aImplModule(_rxContext) -{ - if ( !m_xContext.is() ) - throw NullPointerException(); - - osl_atomic_increment( &m_refCount ); - try - { - Reference< XDesktop2 > xDesktop = Desktop::create( m_xContext); - xDesktop->addTerminateListener( this ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - osl_atomic_decrement( &m_refCount ); -} - -void KabDriver::disposing() -{ - ::osl::MutexGuard aGuard(m_aMutex); - - // when driver will be destroyed so all our connections have to be destroyed as well - for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i) - { - Reference< XComponent > xComp(i->get(), UNO_QUERY); - if (xComp.is()) - xComp->dispose(); - } - m_xConnections.clear(); - - WeakComponentImplHelperBase::disposing(); -} -// static ServiceInfo - -OUString KabDriver::getImplementationName_Static( ) -{ - return OUString("com.sun.star.comp.sdbc." KAB_SERVICE_NAME ".Driver"); -} - -Sequence< OUString > KabDriver::getSupportedServiceNames_Static( ) -{ - // which service is supported - // for more information @see com.sun.star.sdbc.Driver - Sequence<OUString> aSNS { "com.sun.star.sdbc.Driver" }; - - return aSNS; -} - -OUString SAL_CALL KabDriver::getImplementationName( ) -{ - return getImplementationName_Static(); -} - -sal_Bool SAL_CALL KabDriver::supportsService( const OUString& _rServiceName ) -{ - return cppu::supportsService(this, _rServiceName); -} - -Sequence< OUString > SAL_CALL KabDriver::getSupportedServiceNames( ) -{ - return getSupportedServiceNames_Static(); -} - -Reference< XConnection > SAL_CALL KabDriver::connect( const OUString&, const Sequence< PropertyValue >& ) -{ - ::osl::MutexGuard aGuard(m_aMutex); - - m_aImplModule.init(); - - // create a new connection with the given properties and append it to our vector - // perhaps we should pass url and info into createConnection: - // perhaps we should analyze the URL to know whether the addressbook is local, over LDAP, etc... - // perhaps we should get some user and password information from "info" properties - Reference< XConnection > xConnection(m_aImplModule.createConnection(this)); - - // remember it - m_xConnections.push_back( WeakReferenceHelper( xConnection ) ); - - return xConnection; -} - -sal_Bool SAL_CALL KabDriver::acceptsURL( const OUString& url ) -{ - ::osl::MutexGuard aGuard(m_aMutex); - - if ( !m_aImplModule.isKDEPresent() ) - return false; - - // here we have to look whether we support this URL format - return url.startsWith("sdbc:address:" KAB_SERVICE_NAME); -} - -Sequence< DriverPropertyInfo > SAL_CALL KabDriver::getPropertyInfo( const OUString&, const Sequence< PropertyValue >& ) -{ - // if you have something special to say, return it here :-) - return Sequence< DriverPropertyInfo >(); -} - -sal_Int32 SAL_CALL KabDriver::getMajorVersion( ) -{ - return KAB_DRIVER_VERSION_MAJOR; -} - -sal_Int32 SAL_CALL KabDriver::getMinorVersion( ) -{ - return KAB_DRIVER_VERSION_MINOR; -} - -void SAL_CALL KabDriver::queryTermination( const EventObject& ) -{ - // nothing to do, nothing to veto -} - -void SAL_CALL KabDriver::notifyTermination( const EventObject& ) -{ - m_aImplModule.shutdown(); -} - -void SAL_CALL KabDriver::disposing( const EventObject& ) -{ - // not interested in (this is the disposing of the desktop, if any) -} - -OUString KabDriver::impl_getConfigurationSettingsPath() -{ - OUStringBuffer aPath; - aPath.append( "/org.openoffice.Office.DataAccess/DriverSettings/" ); - aPath.append( "com.sun.star.comp.sdbc." KAB_SERVICE_NAME ".Driver" ); - return aPath.makeStringAndClear(); -} - -Reference< XInterface > SAL_CALL KabDriver::Create( const Reference< XMultiServiceFactory >& _rxFactory ) -{ - return *(new KabDriver( comphelper::getComponentContext(_rxFactory))); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KDriver.hxx b/connectivity/source/drivers/kab/KDriver.hxx deleted file mode 100644 index 8a94db9ed180..000000000000 --- a/connectivity/source/drivers/kab/KDriver.hxx +++ /dev/null @@ -1,197 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KDRIVER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KDRIVER_HXX - -#include <com/sun/star/sdbc/XDriver.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/frame/XTerminateListener.hpp> -#include <comphelper/processfactory.hxx> -#include <cppuhelper/compbase.hxx> -#include <osl/module.h> - -namespace connectivity -{ - namespace kab - { - class KabDriver; - - extern "C" { - typedef css::uno::XInterface * (SAL_CALL * ConnectionFactoryFunction)( - css::uno::Reference<css::uno::XComponentContext> const &, - css::uno::Reference<css::sdbc::XDriver> const &); - typedef void (SAL_CALL * ApplicationInitFunction)( void ); - typedef void (SAL_CALL * ApplicationShutdownFunction)( void ); - typedef int (SAL_CALL * KDEVersionCheckFunction)( void ); - } - - typedef std::vector< css::uno::WeakReferenceHelper > OWeakRefArray; - - - // = KabImplModule - - class KabImplModule - { - private: - css::uno::Reference< css::uno::XComponentContext > - m_xContext; - - /// Did we already attempt to load the module and to retrieve the symbols? - bool m_bAttemptedLoadModule; - /// Did we already check the KDE version and initialize the impl module (or at least attempted to)? - bool m_bAttemptedInitialize; - - oslModule m_hConnectorModule; - ConnectionFactoryFunction m_pConnectionFactoryFunc; - ApplicationInitFunction m_pApplicationInitFunc; - ApplicationShutdownFunction m_pApplicationShutdownFunc; - KDEVersionCheckFunction m_pKDEVersionCheckFunc; - - public: - explicit KabImplModule( const css::uno::Reference< css::uno::XComponentContext >& _rxContext ); - - /** determines whether there is a KDE present in the environment - */ - bool isKDEPresent(); - - enum KDEVersionType - { - eTooOld, - eSupported, - eToNew - }; - /** checks whether the KDE version we're running against is supported - @precond - the module is loaded, i.e impl_loadModule has successfully been called - */ - KDEVersionType matchKDEVersion(); - - /** initializes the implementation module. - - @throws css::uno::RuntimeException - if the module could be loaded, but required symbols are missing - @throws css::sdbc::SQLException - if the KDE version we're running against is not supported, or no KDE was found at all - */ - void init(); - - /** shuts down the impl module (and the KDE application, if we own it) - */ - void shutdown(); - - /** creates a new connection - @precond - <member>init</member> has been called before - @throws css::uno::RuntimeException - if no connection object could be created (which is a severe error, normally impossible) - */ - css::uno::Reference<css::sdbc::XConnection> createConnection( - KabDriver * driver) const; - - private: - /** loads the implementation module and retrieves the needed symbols - - Save against being called multiple times. - - @return <TRUE/> if the module could be loaded successfully. - - @throws css::uno::RuntimeException - if the module could be loaded, but required symbols are missing - */ - bool impl_loadModule(); - - /** unloads the implementation module, and resets all function pointers to <nullptr/> - @precond m_hConnectorModule is not <nullptr/> - */ - void impl_unloadModule(); - - /** determines whether it's allowed to run on a too-new (not confirmed to work) version - */ - bool impl_doAllowNewKDEVersion(); - }; - - - // = KabDriver - - typedef ::cppu::WeakComponentImplHelper< css::sdbc::XDriver, - css::lang::XServiceInfo, - css::frame::XTerminateListener > KDriver_BASE; - class KabDriver : public KDriver_BASE - { - protected: - ::osl::Mutex m_aMutex; // mutex is need to control member access - OWeakRefArray m_xConnections; // vector containing a list of all the - // KabConnection objects for this Driver - css::uno::Reference< css::uno::XComponentContext > - m_xContext; // the multi-service factory - KabImplModule m_aImplModule; - - public: - static css::uno::Reference< css::uno::XInterface > SAL_CALL Create(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory); - - // XServiceInfo - static versions - static OUString getImplementationName_Static( ); - static css::uno::Sequence< OUString > getSupportedServiceNames_Static( ); - - /** returns the path of our configuration settings - */ - static OUString impl_getConfigurationSettingsPath(); - - protected: - explicit KabDriver(const css::uno::Reference< css::uno::XComponentContext >& _rxContext); - - // OComponentHelper - virtual void SAL_CALL disposing() override; - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName( ) override; - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; - virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; - - // XDriver - virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL connect( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override; - virtual sal_Bool SAL_CALL acceptsURL( const OUString& url ) override; - virtual css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override; - virtual sal_Int32 SAL_CALL getMajorVersion() override; - virtual sal_Int32 SAL_CALL getMinorVersion() override; - - // XTerminateListener - virtual void SAL_CALL queryTermination( const css::lang::EventObject& Event ) override; - virtual void SAL_CALL notifyTermination( const css::lang::EventObject& Event ) override; - - // XEventListener - virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; - - private: - /** shuts down the library which contains the real implementations - - This method is safe against being called multiple times - - @precond our mutex is locked - */ - void impl_shutdownImplementationModule(); - }; - } - -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KDRIVER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KPreparedStatement.cxx b/connectivity/source/drivers/kab/KPreparedStatement.cxx deleted file mode 100644 index 5cf649696e4d..000000000000 --- a/connectivity/source/drivers/kab/KPreparedStatement.cxx +++ /dev/null @@ -1,326 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "KPreparedStatement.hxx" -#include "propertyids.hxx" -#include <connectivity/dbexception.hxx> -#include <connectivity/dbtools.hxx> -#include "resource/kab_res.hrc" -#include "resource/sharedresources.hxx" - -using namespace connectivity::kab; -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::sdbc; -using namespace com::sun::star::util; - -IMPLEMENT_SERVICE_INFO(KabPreparedStatement, "com.sun.star.sdbc.drivers.KabPreparedStatement", "com.sun.star.sdbc.PreparedStatement"); - -void KabPreparedStatement::checkAndResizeParameters(sal_Int32 nParams) -{ - if ( !m_aParameterRow.is() ) - m_aParameterRow = new OValueVector(); - - if (nParams < 1) - ::dbtools::throwInvalidIndexException(*this); - - if (nParams >= (sal_Int32) (m_aParameterRow->get()).size()) - (m_aParameterRow->get()).resize(nParams); -} - -void KabPreparedStatement::setKabFields() const -{ - ::rtl::Reference<connectivity::OSQLColumns> xColumns; // selected columns - - xColumns = m_aSQLIterator.getSelectColumns(); - if (!xColumns.is()) - { - ::connectivity::SharedResources aResources; - const OUString sError( aResources.getResourceString( - STR_INVALID_COLUMN_SELECTION - ) ); - ::dbtools::throwGenericSQLException(sError,nullptr); - } - m_xMetaData->setKabFields(xColumns); -} - -void KabPreparedStatement::resetParameters() const -{ - m_nParameterIndex = 0; -} - -void KabPreparedStatement::getNextParameter(OUString &rParameter) const -{ - if (m_nParameterIndex >= (sal_Int32) (m_aParameterRow->get()).size()) - { - ::connectivity::SharedResources aResources; - const OUString sError( aResources.getResourceString( - STR_INVALID_PARA_COUNT - ) ); - ::dbtools::throwGenericSQLException(sError,*const_cast<KabPreparedStatement *>(this)); - } // if (m_nParameterIndex >= (sal_Int32) (*m_aParameterRow).size()) - - rParameter = (m_aParameterRow->get())[m_nParameterIndex]; - - m_nParameterIndex++; -} - -KabPreparedStatement::KabPreparedStatement( - KabConnection* _pConnection, - const OUString& sql) - : KabPreparedStatement_BASE(_pConnection), - m_sSqlStatement(sql), - m_bPrepared(false), - m_nParameterIndex(0), - m_aParameterRow() -{ -} - -KabPreparedStatement::~KabPreparedStatement() -{ -} - -void KabPreparedStatement::disposing() -{ - KabPreparedStatement_BASE::disposing(); - - if (m_aParameterRow.is()) - { - m_aParameterRow->get().clear(); - m_aParameterRow = nullptr; - } -} - -Reference< XResultSetMetaData > SAL_CALL KabPreparedStatement::getMetaData() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); - - if (!m_xMetaData.is()) - { - m_xMetaData = new KabResultSetMetaData; - setKabFields(); - } - Reference< XResultSetMetaData > xMetaData = m_xMetaData.get(); - return xMetaData; -} - -void SAL_CALL KabPreparedStatement::close() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); - - // Reset last warning message - try { - clearWarnings (); - KabCommonStatement::close(); - } - catch (SQLException &) { - // If we get an error, ignore - } - - // Remove this Statement object from the Connection object's - // list -} - -sal_Bool SAL_CALL KabPreparedStatement::execute() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); - - Reference< XResultSet> xRS = KabCommonStatement::executeQuery(m_sSqlStatement); - - return xRS.is(); -} - -sal_Int32 SAL_CALL KabPreparedStatement::executeUpdate() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); - - // same as in statement with the difference that this statement also can contain parameter - return 0; -} - -Reference< XConnection > SAL_CALL KabPreparedStatement::getConnection() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); - - return m_pConnection; -} - -Reference< XResultSet > SAL_CALL KabPreparedStatement::executeQuery() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); - - Reference< XResultSet > rs = KabCommonStatement::executeQuery(m_sSqlStatement); - - return rs; -} - -void SAL_CALL KabPreparedStatement::setNull(sal_Int32 parameterIndex, sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); - - checkAndResizeParameters(parameterIndex); - - (m_aParameterRow->get())[parameterIndex - 1].setNull(); -} - -void SAL_CALL KabPreparedStatement::setObjectNull(sal_Int32, sal_Int32, const OUString&) -{ - ::dbtools::throwFunctionNotSupportedSQLException("setObjectNull", nullptr); -} - -void SAL_CALL KabPreparedStatement::setBoolean(sal_Int32, sal_Bool) -{ - ::dbtools::throwFunctionNotSupportedSQLException("setBoolean", nullptr); -} - -void SAL_CALL KabPreparedStatement::setByte(sal_Int32, sal_Int8) -{ - ::dbtools::throwFunctionNotSupportedSQLException("setByte", nullptr); -} - -void SAL_CALL KabPreparedStatement::setShort(sal_Int32, sal_Int16) -{ - ::dbtools::throwFunctionNotSupportedSQLException("setShort", nullptr); -} - -void SAL_CALL KabPreparedStatement::setInt(sal_Int32, sal_Int32) -{ - ::dbtools::throwFunctionNotSupportedSQLException("setInt", nullptr); -} - -void SAL_CALL KabPreparedStatement::setLong(sal_Int32, sal_Int64) -{ - ::dbtools::throwFunctionNotSupportedSQLException("", nullptr); -} - -void SAL_CALL KabPreparedStatement::setFloat(sal_Int32, float) -{ - ::dbtools::throwFunctionNotSupportedSQLException("setFloat", nullptr); -} - -void SAL_CALL KabPreparedStatement::setDouble(sal_Int32, double) -{ - ::dbtools::throwFunctionNotSupportedSQLException("setDouble", nullptr); -} - -void SAL_CALL KabPreparedStatement::setString(sal_Int32 parameterIndex, const OUString &x) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); - - checkAndResizeParameters(parameterIndex); - - (m_aParameterRow->get())[parameterIndex - 1] = x; -} - -void SAL_CALL KabPreparedStatement::setBytes(sal_Int32, const Sequence< sal_Int8 >&) -{ - ::dbtools::throwFunctionNotSupportedSQLException("setBytes", nullptr); -} - -void SAL_CALL KabPreparedStatement::setDate(sal_Int32, const Date&) -{ - ::dbtools::throwFunctionNotSupportedSQLException("setDate", nullptr); -} - -void SAL_CALL KabPreparedStatement::setTime(sal_Int32, const css::util::Time&) -{ - ::dbtools::throwFunctionNotSupportedSQLException("setTime", nullptr); -} - -void SAL_CALL KabPreparedStatement::setTimestamp(sal_Int32, const DateTime&) -{ - - ::dbtools::throwFunctionNotSupportedSQLException("setTimestamp", nullptr); -} - -void SAL_CALL KabPreparedStatement::setBinaryStream(sal_Int32, const Reference< css::io::XInputStream >&, sal_Int32) -{ - ::dbtools::throwFunctionNotSupportedSQLException("setBinaryStream", nullptr); -} - -void SAL_CALL KabPreparedStatement::setCharacterStream(sal_Int32, const Reference< css::io::XInputStream >&, sal_Int32) -{ - ::dbtools::throwFunctionNotSupportedSQLException("setCharacterStream", nullptr); -} - -void SAL_CALL KabPreparedStatement::setObject(sal_Int32 parameterIndex, const Any& x) -{ - if(!::dbtools::implSetObject(this,parameterIndex,x)) - { - throw SQLException(); - } -} - -void SAL_CALL KabPreparedStatement::setObjectWithInfo(sal_Int32, const Any&, sal_Int32, sal_Int32) -{ - ::dbtools::throwFunctionNotSupportedSQLException("setObjectWithInfo", nullptr); -} - -void SAL_CALL KabPreparedStatement::setRef(sal_Int32, const Reference< XRef >&) -{ - ::dbtools::throwFunctionNotSupportedSQLException("setRef", nullptr); -} - -void SAL_CALL KabPreparedStatement::setBlob(sal_Int32, const Reference< XBlob >&) -{ - ::dbtools::throwFunctionNotSupportedSQLException("setBlob", nullptr); -} - -void SAL_CALL KabPreparedStatement::setClob(sal_Int32, const Reference< XClob >&) -{ - ::dbtools::throwFunctionNotSupportedSQLException("setClob", nullptr); -} - -void SAL_CALL KabPreparedStatement::setArray(sal_Int32, const Reference< XArray >&) -{ - ::dbtools::throwFunctionNotSupportedSQLException("setArray", nullptr); -} - -void SAL_CALL KabPreparedStatement::clearParameters() -{ - ::dbtools::throwFunctionNotSupportedSQLException("clearParameters", nullptr); -} - -void KabPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) -{ - switch (nHandle) - { - case PROPERTY_ID_RESULTSETCONCURRENCY: - break; - case PROPERTY_ID_RESULTSETTYPE: - break; - case PROPERTY_ID_FETCHDIRECTION: - break; - case PROPERTY_ID_USEBOOKMARKS: - break; - default: - KabCommonStatement::setFastPropertyValue_NoBroadcast(nHandle,rValue); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KPreparedStatement.hxx b/connectivity/source/drivers/kab/KPreparedStatement.hxx deleted file mode 100644 index 28b22d8e77a3..000000000000 --- a/connectivity/source/drivers/kab/KPreparedStatement.hxx +++ /dev/null @@ -1,114 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KPREPAREDSTATEMENT_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KPREPAREDSTATEMENT_HXX - -#include "KStatement.hxx" -#include "KResultSetMetaData.hxx" -#include <connectivity/FValue.hxx> -#include <com/sun/star/sdbc/XParameters.hpp> -#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> -#include <cppuhelper/implbase.hxx> - -namespace connectivity -{ - namespace kab - { - typedef ::cppu::ImplInheritanceHelper< KabCommonStatement, - css::sdbc::XPreparedStatement, - css::sdbc::XParameters, - css::sdbc::XResultSetMetaDataSupplier, - css::lang::XServiceInfo> KabPreparedStatement_BASE; - - class KabPreparedStatement : public KabPreparedStatement_BASE - { - protected: - OUString m_sSqlStatement; - ::rtl::Reference< KabResultSetMetaData > - m_xMetaData; - bool m_bPrepared; - mutable sal_Int32 m_nParameterIndex; - OValueRow m_aParameterRow; - - void checkAndResizeParameters(sal_Int32 nParams); - void setKabFields() const; - - protected: - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const css::uno::Any& rValue) override; - - virtual void resetParameters() const override; - virtual void getNextParameter(OUString &rParameter) const override; - virtual ~KabPreparedStatement() override; - - public: - DECLARE_SERVICE_INFO(); - KabPreparedStatement(KabConnection* _pConnection, const OUString& sql); - - // OComponentHelper - virtual void SAL_CALL disposing() override; - - // XPreparedStatement - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery( ) override; - virtual sal_Int32 SAL_CALL executeUpdate( ) override; - virtual sal_Bool SAL_CALL execute( ) override; - virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( ) override; - using KabCommonStatement::executeQuery; - using KabCommonStatement::executeUpdate; - using KabCommonStatement::execute; - - // XParameters - virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) override; - virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& typeName ) override; - virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) override; - virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) override; - virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) override; - virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) override; - virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) override; - virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) override; - virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) override; - virtual void SAL_CALL setString( sal_Int32 parameterIndex, const OUString& x ) override; - virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const css::uno::Sequence< sal_Int8 >& x ) override; - virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const css::util::Date& x ) override; - virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const css::util::Time& x ) override; - virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const css::util::DateTime& x ) override; - virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length ) override; - virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length ) override; - virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const css::uno::Any& x ) override; - virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const css::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) override; - virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XRef >& x ) override; - virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XBlob >& x ) override; - virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XClob >& x ) override; - virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XArray >& x ) override; - virtual void SAL_CALL clearParameters( ) override; - - // XCloseable - virtual void SAL_CALL close( ) override; - - // XResultSetMetaDataSupplier - virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) override; - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KPREPAREDSTATEMENT_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KResultSet.cxx b/connectivity/source/drivers/kab/KResultSet.cxx deleted file mode 100644 index 5527b998923c..000000000000 --- a/connectivity/source/drivers/kab/KResultSet.cxx +++ /dev/null @@ -1,981 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "KResultSet.hxx" -#include "KResultSetMetaData.hxx" -#include "KConnection.hxx" -#include "kcondition.hxx" -#include "korder.hxx" -#include "kfields.hxx" -#include <com/sun/star/beans/PropertyAttribute.hpp> -#include <com/sun/star/sdbcx/CompareBookmark.hpp> -#include "TConnection.hxx" -#include <connectivity/dbexception.hxx> -#include "resource/kab_res.hrc" -#include "resource/sharedresources.hxx" -#include <tools/time.hxx> - -using namespace connectivity::kab; -using namespace cppu; -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::beans; -using namespace com::sun::star::sdbc; -using namespace com::sun::star::sdbcx; -using namespace com::sun::star::io; -namespace cssu = com::sun::star::util; - -IMPLEMENT_SERVICE_INFO(KabResultSet, "com.sun.star.sdbc.drivers.KabResultSet", "com.sun.star.sdbc.ResultSet"); - -KabResultSet::KabResultSet(KabCommonStatement* pStmt) - : KabResultSet_BASE(m_aMutex), - OPropertySetHelper(KabResultSet_BASE::rBHelper), - m_xStatement(pStmt), - m_xMetaData(nullptr), - m_aKabAddressees(), - m_nRowPos(-1), - m_bWasNull(true) -{ -} - -KabResultSet::~KabResultSet() -{ -} - -void KabResultSet::allKabAddressees() -{ - KabConnection* pConnection = static_cast< KabConnection *>(m_xStatement->getConnection().get()); - KABC::AddressBook* pAddressBook = pConnection->getAddressBook(); - - m_aKabAddressees = pAddressBook->allAddressees(); -} - -void KabResultSet::someKabAddressees(const KabCondition *pCondition) -{ - KabConnection* pConnection = static_cast< KabConnection *>(m_xStatement->getConnection().get()); - KABC::AddressBook* pAddressBook = pConnection->getAddressBook(); - - KABC::AddressBook::Iterator iterator; - - for (iterator = pAddressBook->begin(); - iterator != pAddressBook->end(); - ++iterator) - { - if (pCondition->eval(*iterator)) - m_aKabAddressees.push_back(*iterator); - } -} - -void KabResultSet::sortKabAddressees(const KabOrder *pOrder) -{ - // We do not use class KAddresseeList, which has a sorting algorithm in it, because - // it uses templates. It would expand to more or less the same code as the one - // which follows, but it would need not be called in a much less convenient way. - - KABC::Addressee::List::Iterator - begin = m_aKabAddressees.begin(), - end = m_aKabAddressees.end(), - iterator; - - // Bubble sort. Feel free to implement a better algorithm. - while (begin != end) - { - end--; - for (iterator = begin; iterator != end; ++iterator) - { - if (pOrder->compare(*iterator, *end) > 0) - qSwap(*iterator, *end); - } - } -} - -void KabResultSet::disposing() -{ - OPropertySetHelper::disposing(); - - ::osl::MutexGuard aGuard(m_aMutex); - -m_xStatement.clear(); -m_xMetaData.clear(); -} - -Any SAL_CALL KabResultSet::queryInterface(const Type & rType) -{ - Any aRet = OPropertySetHelper::queryInterface(rType); - if (!aRet.hasValue()) - aRet = KabResultSet_BASE::queryInterface(rType); - return aRet; -} - -void SAL_CALL KabResultSet::acquire() throw() -{ - KabResultSet_BASE::acquire(); -} - -void SAL_CALL KabResultSet::release() throw() -{ - KabResultSet_BASE::release(); -} - -Sequence< Type > SAL_CALL KabResultSet::getTypes() -{ - OTypeCollection aTypes( - cppu::UnoType<css::beans::XMultiPropertySet>::get(), - cppu::UnoType<css::beans::XFastPropertySet>::get(), - cppu::UnoType<css::beans::XPropertySet>::get()); - - return comphelper::concatSequences(aTypes.getTypes(), KabResultSet_BASE::getTypes()); -} - -css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL KabResultSet::getPropertySetInfo( ) -{ - return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); -} - -sal_Int32 SAL_CALL KabResultSet::findColumn(const OUString& columnName) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - // find the first column with the name columnName - Reference< XResultSetMetaData > xMeta = getMetaData(); - sal_Int32 nLen = xMeta->getColumnCount(); - - for (sal_Int32 i = 1; i <= nLen; ++i) - if (xMeta->isCaseSensitive(i) ? - columnName == xMeta->getColumnName(i) : - columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i))) - return i; - - ::dbtools::throwInvalidColumnException( columnName, *this ); - assert(false); - return 0; // Never reached -} - -OUString SAL_CALL KabResultSet::getString(sal_Int32 columnIndex) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - OUString aRet; - sal_Int32 nAddressees = m_aKabAddressees.size(); - ::KABC::Field::List aFields = ::KABC::Field::allFields(); - - if (m_nRowPos != -1 && m_nRowPos != nAddressees && m_xMetaData.is()) - { - sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(columnIndex); - QString aQtName; - - switch (nFieldNumber) - { - case KAB_FIELD_REVISION: -// trigger an exception here -m_bWasNull = true; -return aRet; - default: - aQtName = aFields[nFieldNumber - KAB_DATA_FIELDS]->value(m_aKabAddressees[m_nRowPos]); - } -// KDE address book currently does not use nullptr values. -// But it might do it someday - if (!aQtName.isNull()) - { - m_bWasNull = false; - aRet = OUString(reinterpret_cast<const sal_Unicode *>(aQtName.ucs2())); - return aRet; - } - } -// Trigger an exception ? - m_bWasNull = true; - return aRet; -} - -sal_Bool SAL_CALL KabResultSet::getBoolean(sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - -::dbtools::throwFunctionNotSupportedSQLException("getBoolean", nullptr); - - return false; -} - -sal_Int8 SAL_CALL KabResultSet::getByte(sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - -::dbtools::throwFunctionNotSupportedSQLException("getByte", nullptr); - - sal_Int8 nRet = 0; - return nRet; -} - -sal_Int16 SAL_CALL KabResultSet::getShort(sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - -::dbtools::throwFunctionNotSupportedSQLException("getShort", nullptr); - - sal_Int16 nRet = 0; - return nRet; -} - -sal_Int32 SAL_CALL KabResultSet::getInt(sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - -::dbtools::throwFunctionNotSupportedSQLException("getInt", nullptr); - - sal_Int32 nRet = 0; - return nRet; -} - -sal_Int64 SAL_CALL KabResultSet::getLong(sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - -::dbtools::throwFunctionNotSupportedSQLException("getLong", nullptr); - - return sal_Int64(); -} - -float SAL_CALL KabResultSet::getFloat(sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - -::dbtools::throwFunctionNotSupportedSQLException("getFloat", nullptr); - - float nVal(0); - return nVal; -} - -double SAL_CALL KabResultSet::getDouble(sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - -::dbtools::throwFunctionNotSupportedSQLException("getDouble", nullptr); - - double nRet = 0; - return nRet; -} - -Sequence< sal_Int8 > SAL_CALL KabResultSet::getBytes(sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - -::dbtools::throwFunctionNotSupportedSQLException("", nullptr); - - return Sequence< sal_Int8 >(); -} - -cssu::Date SAL_CALL KabResultSet::getDate(sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - -::dbtools::throwFunctionNotSupportedSQLException("getDate", nullptr); - - cssu::Date aRet; - return aRet; -} - -cssu::Time SAL_CALL KabResultSet::getTime(sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - -::dbtools::throwFunctionNotSupportedSQLException("getTime", nullptr); - - cssu::Time nRet; - return nRet; -} - -cssu::DateTime SAL_CALL KabResultSet::getTimestamp(sal_Int32 columnIndex) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - cssu::DateTime nRet; - sal_Int32 nAddressees = m_aKabAddressees.size(); - - if (m_nRowPos != -1 && m_nRowPos != nAddressees && m_xMetaData.is()) - { - sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(columnIndex); - - if (nFieldNumber == KAB_FIELD_REVISION) - { - QDateTime nRevision(m_aKabAddressees[m_nRowPos].revision()); - - if (!nRevision.isNull()) - { - m_bWasNull = false; - nRet.Year = nRevision.date().year(); - nRet.Month = nRevision.date().month(); - nRet.Day = nRevision.date().day(); - nRet.Hours = nRevision.time().hour(); - nRet.Minutes = nRevision.time().minute(); - nRet.Seconds = nRevision.time().second(); - nRet.NanoSeconds = nRevision.time().msec() * ::tools::Time::nanoPerMilli; - return nRet; - } - } - else { - ; - } -// trigger an exception here - } -// Trigger an exception ? - m_bWasNull = true; - return nRet; -} - -Reference< XInputStream > SAL_CALL KabResultSet::getBinaryStream(sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - -::dbtools::throwFunctionNotSupportedSQLException("getBinaryStream", nullptr); - - return nullptr; -} - -Reference< XInputStream > SAL_CALL KabResultSet::getCharacterStream(sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - -::dbtools::throwFunctionNotSupportedSQLException("getCharacterStream", nullptr); - - return nullptr; -} - -Any SAL_CALL KabResultSet::getObject(sal_Int32, const Reference< css::container::XNameAccess >&) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - -::dbtools::throwFunctionNotSupportedSQLException("getObject", nullptr); - - return Any(); -} - -Reference< XRef > SAL_CALL KabResultSet::getRef(sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - -::dbtools::throwFunctionNotSupportedSQLException("getRef", nullptr); - - return nullptr; -} - -Reference< XBlob > SAL_CALL KabResultSet::getBlob(sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - -::dbtools::throwFunctionNotSupportedSQLException("getBlob", nullptr); - - return nullptr; -} - -Reference< XClob > SAL_CALL KabResultSet::getClob(sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - -::dbtools::throwFunctionNotSupportedSQLException("getClob", nullptr); - - return nullptr; -} - -Reference< XArray > SAL_CALL KabResultSet::getArray(sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - -::dbtools::throwFunctionNotSupportedSQLException("getArray", nullptr); - - return nullptr; -} - -Reference< XResultSetMetaData > SAL_CALL KabResultSet::getMetaData() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - if (!m_xMetaData.is()) - m_xMetaData = new KabResultSetMetaData; - - Reference< XResultSetMetaData > xMetaData = m_xMetaData.get(); - return xMetaData; -} - -sal_Bool SAL_CALL KabResultSet::isBeforeFirst() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - if (m_nRowPos == -1) - return true; - - return false; -} - -sal_Bool SAL_CALL KabResultSet::isAfterLast() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - sal_Int32 nAddressees = m_aKabAddressees.size(); - if (m_nRowPos == nAddressees) - return true; - - return false; -} - -sal_Bool SAL_CALL KabResultSet::isFirst() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - if (m_nRowPos == 0) - return true; - - return false; -} - -sal_Bool SAL_CALL KabResultSet::isLast() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - sal_Int32 nAddressees = m_aKabAddressees.size(); - if (m_nRowPos == nAddressees - 1) - return true; - - return false; -} - -void SAL_CALL KabResultSet::beforeFirst() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - // move before the first row - m_nRowPos = -1; -} - -void SAL_CALL KabResultSet::afterLast() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - // move after the last row - sal_Int32 nAddressees = m_aKabAddressees.size(); - m_nRowPos = nAddressees; -} - -void SAL_CALL KabResultSet::close() -{ - { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - } - dispose(); -} - -sal_Bool SAL_CALL KabResultSet::first() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - sal_Int32 nAddressees = m_aKabAddressees.size(); - if (nAddressees == 0) - return false; - - m_nRowPos = 0; - return true; -} - -sal_Bool SAL_CALL KabResultSet::last() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - sal_Int32 nAddressees = m_aKabAddressees.size(); - if (nAddressees == 0) - return false; - - m_nRowPos = nAddressees - 1; - return true; -} - -sal_Int32 SAL_CALL KabResultSet::getRow() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - return m_nRowPos; -} - -sal_Bool SAL_CALL KabResultSet::absolute(sal_Int32 row) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - sal_Int32 nAddressees = m_aKabAddressees.size(); - if (row <= -1 || - row >= nAddressees) - return false; - - m_nRowPos = row; - return true; -} - -sal_Bool SAL_CALL KabResultSet::relative(sal_Int32 row) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - return absolute(m_nRowPos + row); -} - -sal_Bool SAL_CALL KabResultSet::next() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - return absolute(m_nRowPos + 1); -} - -sal_Bool SAL_CALL KabResultSet::previous() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - return absolute(m_nRowPos - 1); -} - -Reference< XInterface > SAL_CALL KabResultSet::getStatement() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - Reference< XStatement > xStatement = m_xStatement.get(); - return xStatement; -} - -sal_Bool SAL_CALL KabResultSet::rowDeleted() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - return false; -} - -sal_Bool SAL_CALL KabResultSet::rowInserted() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - return false; -} - -sal_Bool SAL_CALL KabResultSet::rowUpdated() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - return false; -} - -sal_Bool SAL_CALL KabResultSet::wasNull() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - return m_bWasNull; -} - -void SAL_CALL KabResultSet::cancel() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::clearWarnings() -{ -} - -Any SAL_CALL KabResultSet::getWarnings() -{ - return Any(); -} - -void SAL_CALL KabResultSet::insertRow() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - // you only have to implement this if you want to insert new rows -} - -void SAL_CALL KabResultSet::updateRow() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - // only when you allow updates -} - -void SAL_CALL KabResultSet::deleteRow() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::cancelRowUpdates() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::moveToInsertRow() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - // only when you allow inserts -} - -void SAL_CALL KabResultSet::moveToCurrentRow() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::updateNull(sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::updateBoolean(sal_Int32, sal_Bool) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::updateByte(sal_Int32, sal_Int8) -{ - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - ::osl::MutexGuard aGuard( m_aMutex ); -} - -void SAL_CALL KabResultSet::updateShort(sal_Int32, sal_Int16) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::updateInt(sal_Int32, sal_Int32) -{ - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - ::osl::MutexGuard aGuard( m_aMutex ); -} - -void SAL_CALL KabResultSet::updateLong(sal_Int32, sal_Int64) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::updateFloat(sal_Int32, float) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::updateDouble(sal_Int32, double) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::updateString(sal_Int32, const OUString&) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::updateBytes(sal_Int32, const Sequence< sal_Int8 >&) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::updateDate(sal_Int32, const cssu::Date&) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::updateTime(sal_Int32, const cssu::Time&) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::updateTimestamp(sal_Int32, const cssu::DateTime&) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::updateBinaryStream(sal_Int32, const Reference< XInputStream >&, sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::updateCharacterStream(sal_Int32, const Reference< XInputStream >&, sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::refreshRow() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::updateObject(sal_Int32, const Any&) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -void SAL_CALL KabResultSet::updateNumericObject(sal_Int32, const Any&, sal_Int32) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); -} - -// XRowLocate -Any SAL_CALL KabResultSet::getBookmark() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - sal_Int32 nAddressees = m_aKabAddressees.size(); - - if (m_nRowPos != -1 && m_nRowPos != nAddressees) - { - QString aQtName = m_aKabAddressees[m_nRowPos].uid(); - OUString sUniqueIdentifier = OUString(reinterpret_cast<const sal_Unicode *>(aQtName.ucs2())); - return makeAny(sUniqueIdentifier); - } - return Any(); -} - -sal_Bool SAL_CALL KabResultSet::moveToBookmark(const Any& bookmark) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - OUString sBookmark = comphelper::getString(bookmark); - sal_Int32 nAddressees = m_aKabAddressees.size(); - - for (sal_Int32 nRow = 0; nRow < nAddressees; nRow++) - { - QString aQtName = m_aKabAddressees[nRow].uid(); - OUString sUniqueIdentifier = OUString(reinterpret_cast<const sal_Unicode *>(aQtName.ucs2())); - - if (sUniqueIdentifier == sBookmark) - { - m_nRowPos = nRow; - return true; - } - } - return false; -} - -sal_Bool SAL_CALL KabResultSet::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - sal_Int32 nRowSave = m_nRowPos; - - if (moveToBookmark(bookmark)) - { - sal_Int32 nAddressees = m_aKabAddressees.size(); - - m_nRowPos += rows; - - if (-1 < m_nRowPos && m_nRowPos < nAddressees) - return true; - } - - m_nRowPos = nRowSave; - return false; -} - -sal_Int32 SAL_CALL KabResultSet::compareBookmarks(const Any& firstItem, const Any& secondItem) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - OUString sFirst = comphelper::getString(firstItem); - OUString sSecond = comphelper::getString(secondItem); - - if (sFirst < sSecond) - return CompareBookmark::LESS; - if (sFirst > sSecond) - return CompareBookmark::GREATER; - return CompareBookmark::EQUAL; -} - -sal_Bool SAL_CALL KabResultSet::hasOrderedBookmarks() -{ - return false; -} - -sal_Int32 SAL_CALL KabResultSet::hashBookmark(const Any& bookmark) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - OUString sBookmark = comphelper::getString(bookmark); - - return sBookmark.hashCode(); -} - -// XDeleteRows -Sequence< sal_Int32 > SAL_CALL KabResultSet::deleteRows(const Sequence< Any >&) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); - - return Sequence< sal_Int32 >(); -} - -IPropertyArrayHelper* KabResultSet::createArrayHelper() const -{ - Sequence< Property > aProps(6); - Property* pProperties = aProps.getArray(); - sal_Int32 nPos = 0; - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME), - PROPERTY_ID_CURSORNAME, cppu::UnoType<OUString>::get(), PropertyAttribute::READONLY); - - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), - PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0); - - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), - PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0); - - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), - PROPERTY_ID_ISBOOKMARKABLE, cppu::UnoType<bool>::get(), PropertyAttribute::READONLY); - - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), - PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::READONLY); - - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), - PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::READONLY); - - return new OPropertyArrayHelper(aProps); -} - -IPropertyArrayHelper & KabResultSet::getInfoHelper() -{ - return *(this->getArrayHelper()); -} - -sal_Bool KabResultSet::convertFastPropertyValue( - Any &, - Any &, - sal_Int32 nHandle, - const Any& ) -{ - switch (nHandle) - { - case PROPERTY_ID_ISBOOKMARKABLE: - case PROPERTY_ID_CURSORNAME: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - throw css::lang::IllegalArgumentException(); - break; - case PROPERTY_ID_FETCHDIRECTION: - case PROPERTY_ID_FETCHSIZE: - default: - ; - } - return false; -} - -void KabResultSet::setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const Any& ) -{ - switch (nHandle) - { - case PROPERTY_ID_ISBOOKMARKABLE: - case PROPERTY_ID_CURSORNAME: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - throw Exception(); - break; - case PROPERTY_ID_FETCHDIRECTION: - break; - case PROPERTY_ID_FETCHSIZE: - break; - default: - ; - } -} - -void KabResultSet::getFastPropertyValue( - Any& _rValue, - sal_Int32 nHandle) const -{ - switch (nHandle) - { - case PROPERTY_ID_ISBOOKMARKABLE: - _rValue <<= false; - break; - case PROPERTY_ID_CURSORNAME: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - case PROPERTY_ID_FETCHDIRECTION: - case PROPERTY_ID_FETCHSIZE: - ; - } -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KResultSet.hxx b/connectivity/source/drivers/kab/KResultSet.hxx deleted file mode 100644 index 8edef8d9f5d4..000000000000 --- a/connectivity/source/drivers/kab/KResultSet.hxx +++ /dev/null @@ -1,220 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KRESULTSET_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KRESULTSET_HXX - -#include "KStatement.hxx" -#include "KResultSetMetaData.hxx" -#include <shell/kde_headers.h> -#include <com/sun/star/sdbc/XRow.hpp> -#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> -#include <com/sun/star/sdbc/XColumnLocate.hpp> -#include <com/sun/star/sdbc/XResultSetUpdate.hpp> -#include <com/sun/star/sdbc/XRowUpdate.hpp> -#include <com/sun/star/sdbcx/XRowLocate.hpp> -#include <com/sun/star/sdbcx/XDeleteRows.hpp> -#include <cppuhelper/compbase.hxx> - -namespace connectivity -{ - namespace kab - { - /* - ** KabResultSet - */ - typedef ::cppu::WeakComponentImplHelper< css::sdbc::XResultSet, - css::sdbc::XRow, - css::sdbc::XResultSetMetaDataSupplier, - css::util::XCancellable, - css::sdbc::XWarningsSupplier, - css::sdbc::XResultSetUpdate, - css::sdbc::XRowUpdate, - css::sdbcx::XRowLocate, - css::sdbcx::XDeleteRows, - css::sdbc::XCloseable, - css::sdbc::XColumnLocate, - css::lang::XServiceInfo> KabResultSet_BASE; - - class KabResultSet : public cppu::BaseMutex, - public KabResultSet_BASE, - public ::cppu::OPropertySetHelper, - public comphelper::OPropertyArrayUsageHelper<KabResultSet> - { - protected: - ::rtl::Reference< KabCommonStatement > m_xStatement; // the statement that has created this result set - ::rtl::Reference< KabResultSetMetaData > m_xMetaData; // the description of the columns in this result set - ::KABC::Addressee::List m_aKabAddressees; // address book entries matching the query - sal_Int32 m_nRowPos; // the current row within the result set - bool m_bWasNull; // last entry retrieved from this result set was nullptr - - // OPropertyArrayUsageHelper - virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override; - - // OPropertySetHelper - virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; - - virtual sal_Bool SAL_CALL convertFastPropertyValue( - css::uno::Any & rConvertedValue, - css::uno::Any & rOldValue, - sal_Int32 nHandle, - const css::uno::Any& rValue) override; - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const css::uno::Any& rValue) override; - virtual void SAL_CALL getFastPropertyValue( - css::uno::Any& rValue, - sal_Int32 nHandle) const override; - using OPropertySetHelper::getFastPropertyValue; - - // you can't delete objects of this type - virtual ~KabResultSet() override; - - public: - DECLARE_SERVICE_INFO(); - - explicit KabResultSet(KabCommonStatement *pStmt); - - css::uno::Reference< css::uno::XInterface > operator *() - { - return css::uno::Reference< css::uno::XInterface >(*static_cast<KabResultSet_BASE*>(this)); - } - - void allKabAddressees(); - void someKabAddressees(const class KabCondition *pCondition); - void sortKabAddressees(const class KabOrder *pOrder); - - ::rtl::Reference< KabResultSetMetaData > getKabMetaData() const - { return m_xMetaData; } - - // ::cppu::OComponentHelper - virtual void SAL_CALL disposing() override; - - // XInterface - virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; - virtual void SAL_CALL acquire() throw() override; - virtual void SAL_CALL release() throw() override; - - // XTypeProvider - virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; - - // XPropertySet - virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; - - // XResultSet - virtual sal_Bool SAL_CALL isBeforeFirst( ) override; - virtual sal_Bool SAL_CALL isAfterLast( ) override; - virtual sal_Bool SAL_CALL isFirst( ) override; - virtual sal_Bool SAL_CALL isLast( ) override; - virtual void SAL_CALL beforeFirst( ) override; - virtual void SAL_CALL afterLast( ) override; - virtual sal_Bool SAL_CALL first( ) override; - virtual sal_Bool SAL_CALL last( ) override; - virtual sal_Int32 SAL_CALL getRow( ) override; - virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) override; - virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) override; - virtual sal_Bool SAL_CALL next( ) override; - virtual sal_Bool SAL_CALL previous( ) override; - virtual void SAL_CALL refreshRow( ) override; - virtual sal_Bool SAL_CALL rowUpdated( ) override; - virtual sal_Bool SAL_CALL rowInserted( ) override; - virtual sal_Bool SAL_CALL rowDeleted( ) override; - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement( ) override; - - // XRow - virtual sal_Bool SAL_CALL wasNull( ) override; - virtual OUString SAL_CALL getString( sal_Int32 columnIndex ) override; - virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) override; - virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) override; - virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) override; - virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) override; - virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) override; - virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) override; - virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) override; - virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) override; - virtual css::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) override; - virtual css::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) override; - virtual css::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) override; - virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) override; - virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) override; - virtual css::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess >& typeMap ) override; - virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) override; - virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) override; - virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) override; - virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) override; - - // XResultSetMetaDataSupplier - virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) override; - - // XCancellable - virtual void SAL_CALL cancel( ) override; - - // XCloseable - virtual void SAL_CALL close( ) override; - - // XWarningsSupplier - virtual css::uno::Any SAL_CALL getWarnings( ) override; - virtual void SAL_CALL clearWarnings( ) override; - - // XResultSetUpdate - virtual void SAL_CALL insertRow( ) override; - virtual void SAL_CALL updateRow( ) override; - virtual void SAL_CALL deleteRow( ) override; - virtual void SAL_CALL cancelRowUpdates( ) override; - virtual void SAL_CALL moveToInsertRow( ) override; - virtual void SAL_CALL moveToCurrentRow( ) override; - // XRowUpdate - virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) override; - virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) override; - virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) override; - virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) override; - virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) override; - virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) override; - virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) override; - virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) override; - virtual void SAL_CALL updateString( sal_Int32 columnIndex, const OUString& x ) override; - virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const css::uno::Sequence< sal_Int8 >& x ) override; - virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const css::util::Date& x ) override; - virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const css::util::Time& x ) override; - virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const css::util::DateTime& x ) override; - virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length ) override; - virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length ) override; - virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const css::uno::Any& x ) override; - virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const css::uno::Any& x, sal_Int32 scale ) override; - - // XColumnLocate - virtual sal_Int32 SAL_CALL findColumn( const OUString& columnName ) override; - - // XRowLocate - virtual css::uno::Any SAL_CALL getBookmark( ) override; - virtual sal_Bool SAL_CALL moveToBookmark( const css::uno::Any& bookmark ) override; - virtual sal_Bool SAL_CALL moveRelativeToBookmark( const css::uno::Any& bookmark, sal_Int32 rows ) override; - virtual sal_Int32 SAL_CALL compareBookmarks( const css::uno::Any& firstItem, const css::uno::Any& secondItem ) override; - virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) override; - virtual sal_Int32 SAL_CALL hashBookmark( const css::uno::Any& bookmark ) override; - - // XDeleteRows - virtual css::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const css::uno::Sequence< css::uno::Any >& rows ) override; - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KRESULTSET_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KResultSetMetaData.cxx b/connectivity/source/drivers/kab/KResultSetMetaData.cxx deleted file mode 100644 index 88669bd2d6fa..000000000000 --- a/connectivity/source/drivers/kab/KResultSetMetaData.cxx +++ /dev/null @@ -1,177 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "KResultSetMetaData.hxx" -#include "kfields.hxx" -#include "KDatabaseMetaData.hxx" -#include <com/sun/star/sdbc/DataType.hpp> - -using namespace connectivity::kab; -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::sdbc; - -KabResultSetMetaData::KabResultSetMetaData() -{ -} - -KabResultSetMetaData::~KabResultSetMetaData() -{ -} - -void KabResultSetMetaData::setKabFields(const ::rtl::Reference<connectivity::OSQLColumns> &xColumns) -{ - OSQLColumns::Vector::const_iterator aIter; - static const char aName[] = "Name"; - - for (aIter = xColumns->get().begin(); aIter != xColumns->get().end(); ++aIter) - { - OUString aFieldName; - sal_uInt32 nFieldNumber; - - (*aIter)->getPropertyValue(aName) >>= aFieldName; - nFieldNumber = findKabField(aFieldName); - m_aKabFields.push_back(nFieldNumber); - } -} - -sal_Int32 SAL_CALL KabResultSetMetaData::getColumnDisplaySize(sal_Int32 column) -{ - return m_aKabFields[column - 1] < KAB_DATA_FIELDS? 20: 50; -} - -sal_Int32 SAL_CALL KabResultSetMetaData::getColumnType(sal_Int32 column) -{ - return m_aKabFields[column - 1] == KAB_FIELD_REVISION? DataType::TIMESTAMP: DataType::CHAR; -} - -sal_Int32 SAL_CALL KabResultSetMetaData::getColumnCount() -{ - return m_aKabFields.size(); -} - -sal_Bool SAL_CALL KabResultSetMetaData::isCaseSensitive(sal_Int32) -{ - return true; -} - -OUString SAL_CALL KabResultSetMetaData::getSchemaName(sal_Int32) -{ - return OUString(); -} - -OUString SAL_CALL KabResultSetMetaData::getColumnName(sal_Int32 column) -{ - sal_uInt32 nFieldNumber = m_aKabFields[column - 1]; - ::KABC::Field::List aFields = ::KABC::Field::allFields(); - QString aQtName; - - switch (nFieldNumber) - { - case KAB_FIELD_REVISION: - aQtName = KABC::Addressee::revisionLabel(); - break; - default: - aQtName = aFields[nFieldNumber - KAB_DATA_FIELDS]->label(); - } - OUString aName(reinterpret_cast<const sal_Unicode *>(aQtName.ucs2())); - - return aName; -} - -OUString SAL_CALL KabResultSetMetaData::getTableName(sal_Int32) -{ - return KabDatabaseMetaData::getAddressBookTableName(); -} - -OUString SAL_CALL KabResultSetMetaData::getCatalogName(sal_Int32) -{ - return OUString(); -} - -OUString SAL_CALL KabResultSetMetaData::getColumnTypeName(sal_Int32) -{ - return OUString(); -} - -OUString SAL_CALL KabResultSetMetaData::getColumnLabel(sal_Int32) -{ - return OUString(); -} - -OUString SAL_CALL KabResultSetMetaData::getColumnServiceName(sal_Int32) -{ - return OUString(); -} - -sal_Bool SAL_CALL KabResultSetMetaData::isCurrency(sal_Int32) -{ - return false; -} - -sal_Bool SAL_CALL KabResultSetMetaData::isAutoIncrement(sal_Int32) -{ - return false; -} - -sal_Bool SAL_CALL KabResultSetMetaData::isSigned(sal_Int32) -{ - return false; -} - -sal_Int32 SAL_CALL KabResultSetMetaData::getPrecision(sal_Int32) -{ - return 0; -} - -sal_Int32 SAL_CALL KabResultSetMetaData::getScale(sal_Int32) -{ - return 0; -} - -sal_Int32 SAL_CALL KabResultSetMetaData::isNullable(sal_Int32) -{ - return (sal_Int32) true; -// KDE address book currently does not use nullptr values. -// But it might do it someday -} - -sal_Bool SAL_CALL KabResultSetMetaData::isSearchable(sal_Int32) -{ - return true; -} - -sal_Bool SAL_CALL KabResultSetMetaData::isReadOnly(sal_Int32) -{ - return true; -} - -sal_Bool SAL_CALL KabResultSetMetaData::isDefinitelyWritable(sal_Int32) -{ - return false; -} - -sal_Bool SAL_CALL KabResultSetMetaData::isWritable(sal_Int32) -{ - return false; -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KResultSetMetaData.hxx b/connectivity/source/drivers/kab/KResultSetMetaData.hxx deleted file mode 100644 index 5da22c1c6e0a..000000000000 --- a/connectivity/source/drivers/kab/KResultSetMetaData.hxx +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KRESULTSETMETADATA_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KRESULTSETMETADATA_HXX - -#include <connectivity/CommonTools.hxx> -#include <com/sun/star/sdbc/XResultSetMetaData.hpp> -#include <cppuhelper/implbase.hxx> -#include <rtl/ref.hxx> - -namespace connectivity -{ - namespace kab - { - /* - ** KabResultSetMetaData - */ - typedef ::cppu::WeakImplHelper< css::sdbc::XResultSetMetaData> KabResultSetMetaData_BASE; - - class KabResultSetMetaData : public KabResultSetMetaData_BASE - { - std::vector<sal_Int32> m_aKabFields; // for each selected column, contains the number - // of the corresponding KAddressBook field - - protected: - virtual ~KabResultSetMetaData() override; - - public: - KabResultSetMetaData(); - - // avoid ambiguous cast error from the compiler - operator css::uno::Reference< css::sdbc::XResultSetMetaData > () throw() - { return this; } - - void setKabFields( - const ::rtl::Reference<connectivity::OSQLColumns> &xColumns); - sal_uInt32 fieldAtColumn(sal_Int32 columnIndex) const - { return m_aKabFields[columnIndex - 1]; } - - virtual sal_Int32 SAL_CALL getColumnCount( ) override; - virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) override; - virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) override; - virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) override; - virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) override; - virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) override; - virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) override; - virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) override; - virtual OUString SAL_CALL getColumnLabel( sal_Int32 column ) override; - virtual OUString SAL_CALL getColumnName( sal_Int32 column ) override; - virtual OUString SAL_CALL getSchemaName( sal_Int32 column ) override; - virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) override; - virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) override; - virtual OUString SAL_CALL getTableName( sal_Int32 column ) override; - virtual OUString SAL_CALL getCatalogName( sal_Int32 column ) override; - virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) override; - virtual OUString SAL_CALL getColumnTypeName( sal_Int32 column ) override; - virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) override; - virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) override; - virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) override; - virtual OUString SAL_CALL getColumnServiceName( sal_Int32 column ) override; - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KRESULTSETMETADATA_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KServices.cxx b/connectivity/source/drivers/kab/KServices.cxx deleted file mode 100644 index 573643ed9eae..000000000000 --- a/connectivity/source/drivers/kab/KServices.cxx +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <config_vclplug.h> -#include "KDriver.hxx" -#include <cppuhelper/factory.hxx> - -#if ENABLE_TDE - -#define kab_component_getFactory tdeab_component_getFactory - -#endif // ENABLE_TDE - -using namespace connectivity::kab; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::lang::XSingleServiceFactory; -using ::com::sun::star::lang::XMultiServiceFactory; - -typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc) - ( - const Reference< XMultiServiceFactory > & rServiceManager, - const OUString & rComponentName, - ::cppu::ComponentInstantiation pCreateFunction, - const Sequence< OUString > & rServiceNames, - rtl_ModuleCount* - ); - - -struct ProviderRequest -{ - Reference< XSingleServiceFactory > xRet; - Reference< XMultiServiceFactory > const xServiceManager; - OUString const sImplementationName; - - ProviderRequest( - void* pServiceManager, - sal_Char const* pImplementationName - ) - : xServiceManager(static_cast<XMultiServiceFactory*>(pServiceManager)) - , sImplementationName(OUString::createFromAscii(pImplementationName)) - { - } - - bool CREATE_PROVIDER( - const OUString& Implname, - const Sequence< OUString > & Services, - ::cppu::ComponentInstantiation Factory, - createFactoryFunc creator - ) - { - if (!xRet.is() && (Implname == sImplementationName)) - { - try - { - xRet = creator( xServiceManager, sImplementationName,Factory, Services, nullptr); - } - catch(...) - { - } - } - return xRet.is(); - } - - void* getProvider() const { return xRet.get(); } -}; - - -extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL kab_component_getFactory( - const sal_Char* pImplementationName, - void* pServiceManager, - void*) -{ - void* pRet = nullptr; - if (pServiceManager) - { - ProviderRequest aReq(pServiceManager,pImplementationName); - - aReq.CREATE_PROVIDER( - KabDriver::getImplementationName_Static(), - KabDriver::getSupportedServiceNames_Static(), - &KabDriver::Create, - ::cppu::createSingleFactory) - ; - - if (aReq.xRet.is()) - aReq.xRet->acquire(); - - pRet = aReq.getProvider(); - } - - return pRet; -}; - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KStatement.cxx b/connectivity/source/drivers/kab/KStatement.cxx deleted file mode 100644 index eb80ca6590a7..000000000000 --- a/connectivity/source/drivers/kab/KStatement.cxx +++ /dev/null @@ -1,567 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "KStatement.hxx" -#include "KConnection.hxx" -#include "KDriver.hxx" -#include "KResultSet.hxx" -#include "KResultSetMetaData.hxx" -#include "kcondition.hxx" -#include "korder.hxx" -#include "TConnection.hxx" -#include <connectivity/dbexception.hxx> -#include "resource/kab_res.hrc" -#include "resource/sharedresources.hxx" -#include "sqlbison.hxx" - - -using namespace connectivity::kab; -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::beans; -using namespace com::sun::star::sdbc; -using namespace com::sun::star::sdbcx; -using namespace com::sun::star::container; -using namespace com::sun::star::io; -using namespace com::sun::star::util; - -namespace -{ - void lcl_throwError(sal_uInt16 _nErrorId) - { - ::connectivity::SharedResources aResources; - const OUString sError( aResources.getResourceString(_nErrorId) ); - ::dbtools::throwGenericSQLException(sError,nullptr); - } -} - -IMPLEMENT_SERVICE_INFO(KabStatement, "com.sun.star.sdbc.drivers.KabStatement", "com.sun.star.sdbc.Statement"); - -KabCommonStatement::KabCommonStatement(KabConnection* _pConnection ) - : KabCommonStatement_BASE(m_aMutex), - OPropertySetHelper(KabCommonStatement_BASE::rBHelper), - m_aParser(_pConnection->getComponentContext()), - m_aSQLIterator(_pConnection, _pConnection->createCatalog()->getTables(), m_aParser), - m_pParseTree(nullptr), - m_pConnection(_pConnection) -{ - m_pConnection->acquire(); -} - -KabCommonStatement::~KabCommonStatement() -{ -} - -void KabCommonStatement::resetParameters() const -{ - lcl_throwError(STR_PARA_ONLY_PREPARED); -} - -void KabCommonStatement::getNextParameter(OUString &) const -{ - lcl_throwError(STR_PARA_ONLY_PREPARED); -} - -KabCondition *KabCommonStatement::analyseWhereClause(const OSQLParseNode *pParseNode) const -{ - if (pParseNode->count() == 3) - { - const OSQLParseNode *pLeft = pParseNode->getChild(0), - *pMiddle = pParseNode->getChild(1), - *pRight = pParseNode->getChild(2); - - // WHERE ( ... ) ? - if (SQL_ISPUNCTUATION(pLeft, "(") && SQL_ISPUNCTUATION(pRight, ")")) - { - return analyseWhereClause(pMiddle); - } - else if (SQL_ISRULE(pParseNode, comparison_predicate)) - { - if (pLeft->isToken() && pRight->isToken()) - { - switch (pMiddle->getNodeType()) - { - case SQLNodeType::Equal: - // WHERE 0 = 1 - return new KabConditionConstant(pLeft->getTokenValue() == pRight->getTokenValue()); - - case SQLNodeType::NotEqual: - // WHERE 0 <> 1 - // (might not be correct SQL... don't care, handling anyway) - return new KabConditionConstant(pLeft->getTokenValue() != pRight->getTokenValue()); - - default: - break; - } - } - else if (SQL_ISRULE(pLeft, column_ref)) - { - OUString sColumnName, - sTableRange; - - m_aSQLIterator.getColumnRange(pLeft, sColumnName, sTableRange); - - if (pRight->isToken() || SQL_ISRULE(pRight, parameter)) - { - OUString sMatchString; - - if (pRight->isToken()) // WHERE Name = 'Doe' - sMatchString = pRight->getTokenValue(); - else if (SQL_ISRULE(pRight, parameter)) // WHERE Name = ? - getNextParameter(sMatchString); - - switch (pMiddle->getNodeType()) - { - case SQLNodeType::Equal: - // WHERE Name = 'Smith' - return new KabConditionEqual(sColumnName, sMatchString); - - case SQLNodeType::NotEqual: - // WHERE Name <> 'Jones' - return new KabConditionDifferent(sColumnName, sMatchString); - - default: - break; - } - } - } - } - else if (SQL_ISRULE(pParseNode, search_condition)) - { - if (SQL_ISTOKEN(pMiddle, OR)) - { - // WHERE Name = 'Smith' OR Name = 'Jones' - return new KabConditionOr( - analyseWhereClause(pLeft), - analyseWhereClause(pRight)); - } - } - else if (SQL_ISRULE(pParseNode, boolean_term)) - { - if (SQL_ISTOKEN(pMiddle, AND)) - { - // WHERE Name = 'Smith' AND "Given Name" = 'Peter' - return new KabConditionAnd( - analyseWhereClause(pLeft), - analyseWhereClause(pRight)); - } - } - } - else if (SQL_ISRULE(pParseNode, test_for_null) || SQL_ISRULE(pParseNode, like_predicate)) - { - const OSQLParseNode *pLeft = pParseNode->getChild(0); - const OSQLParseNode* pPart2 = pParseNode->getChild(1); - const OSQLParseNode *pMiddleLeft = pPart2->getChild(0), - *pMiddleRight = pPart2->getChild(1), - *pRight = pPart2->getChild(2); - - if (SQL_ISRULE(pParseNode, test_for_null)) - { - if (SQL_ISRULE(pLeft, column_ref) && - SQL_ISTOKEN(pMiddleLeft, IS) && - SQL_ISTOKEN(pRight, NULL)) - { - OUString sColumnName, - sTableRange; - - m_aSQLIterator.getColumnRange(pLeft, sColumnName, sTableRange); - - if (SQL_ISTOKEN(pMiddleRight, NOT)) - { - // WHERE "Mobile Phone" IS NOT nullptr - return new KabConditionNotNull(sColumnName); - } - else - { - // WHERE "Mobile Phone" IS nullptr - return new KabConditionNull(sColumnName); - } - } - } - else if (SQL_ISRULE(pParseNode, like_predicate)) - { - if (SQL_ISRULE(pLeft, column_ref)) - { - OUString sColumnName, - sTableRange; - - m_aSQLIterator.getColumnRange(pLeft, sColumnName, sTableRange); - - if (pMiddleRight->isToken() || SQL_ISRULE(pMiddleRight, parameter)) - { - OUString sMatchString; - - if (pMiddleRight->isToken()) // WHERE Name LIKE 'Sm%' - sMatchString = pMiddleRight->getTokenValue(); - else if (SQL_ISRULE(pMiddleRight, parameter)) // WHERE Name LIKE ? - getNextParameter(sMatchString); - - return new KabConditionSimilar(sColumnName, sMatchString); - } - } - } - } - - lcl_throwError(STR_QUERY_TOO_COMPLEX); - - // Unreachable: - OSL_ASSERT(false); - return nullptr; -} - -KabOrder *KabCommonStatement::analyseOrderByClause(const OSQLParseNode *pParseNode) const -{ - if (SQL_ISRULE(pParseNode, ordering_spec_commalist)) - { - KabComplexOrder *list = new KabComplexOrder(); - sal_uInt32 n = pParseNode->count(); - - // Iterate through the ordering columns - for (sal_uInt32 i = 0; i < n; i++) - { - list->addOrder - (analyseOrderByClause(pParseNode->getChild(i))); - } - - return list; - } - else if (SQL_ISRULE(pParseNode, ordering_spec)) - { - if (pParseNode->count() == 2) - { - OSQLParseNode* pColumnRef = pParseNode->getChild(0); - OSQLParseNode* pAscendingDescending = pParseNode->getChild(1); - - if (SQL_ISRULE(pColumnRef, column_ref)) - { - if (pColumnRef->count() == 3) - pColumnRef = pColumnRef->getChild(2); - - if (pColumnRef->count() == 1) - { - OUString sColumnName = - pColumnRef->getChild(0)->getTokenValue(); - bool bAscending = - !SQL_ISTOKEN(pAscendingDescending, DESC); - - return new KabSimpleOrder(sColumnName, bAscending); - } - } - } - } - lcl_throwError(STR_QUERY_TOO_COMPLEX); - // Unreachable: - OSL_ASSERT(false); - return nullptr; -} - -bool KabCommonStatement::isTableKnown(KabResultSet *pResult) const -{ - // can handle requests like SELECT * FROM addresses addresses - // but cannot handle requests like SELECT * FROM addresses persons - if (m_aSQLIterator.getTables().size() != 1) - return false; - - if (m_aSQLIterator.getTables().begin()->first != pResult->getMetaData()->getTableName(0)) - return false; - - return true; -} - -void KabCommonStatement::setKabFields(KabResultSet *pResult) const -{ - ::rtl::Reference<connectivity::OSQLColumns> xColumns; // selected columns - - xColumns = m_aSQLIterator.getSelectColumns(); - if (!xColumns.is()) - { - lcl_throwError(STR_INVALID_COLUMN_SELECTION); - } - pResult->getKabMetaData()->setKabFields(xColumns); -} - -void KabCommonStatement::selectAddressees(KabResultSet *pResult) const -{ - const OSQLParseNode *pParseNode; - - pParseNode = m_aSQLIterator.getWhereTree(); - if (pParseNode != nullptr) - { - if (SQL_ISRULE(pParseNode, where_clause)) - { - resetParameters(); - pParseNode = pParseNode->getChild(1); - KabCondition *pCondition = analyseWhereClause(pParseNode); - if (pCondition->isAlwaysTrue()) - pResult->allKabAddressees(); - else if (!pCondition->isAlwaysFalse()) - pResult->someKabAddressees(pCondition); - delete pCondition; - return; - } - } - - // no WHERE clause: get all rows - pResult->allKabAddressees(); -} - -void KabCommonStatement::sortAddressees(KabResultSet *pResult) const -{ - const OSQLParseNode *pParseNode; - - pParseNode = m_aSQLIterator.getOrderTree(); - if (pParseNode != nullptr) - { - if (SQL_ISRULE(pParseNode, opt_order_by_clause)) - { - pParseNode = pParseNode->getChild(2); - KabOrder *pOrder = analyseOrderByClause(pParseNode); - pResult->sortKabAddressees(pOrder); - delete pOrder; - } - } -} - -Any SAL_CALL KabCommonStatement::queryInterface( const Type & rType ) -{ - Any aRet = KabCommonStatement_BASE::queryInterface(rType); - if (!aRet.hasValue()) - aRet = OPropertySetHelper::queryInterface(rType); - return aRet; -} - -Sequence< Type > SAL_CALL KabCommonStatement::getTypes( ) -{ - ::cppu::OTypeCollection aTypes( cppu::UnoType<XMultiPropertySet>::get(), - cppu::UnoType<XFastPropertySet>::get(), - cppu::UnoType<XPropertySet>::get()); - - return comphelper::concatSequences(aTypes.getTypes(),KabCommonStatement_BASE::getTypes()); -} - -void SAL_CALL KabCommonStatement::cancel( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); - // cancel the current sql statement -} - -void SAL_CALL KabCommonStatement::close( ) -{ - { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); - - } - dispose(); -} - -sal_Bool SAL_CALL KabCommonStatement::execute( - const OUString& sql ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); - - Reference< XResultSet > xRS = executeQuery(sql); - - return xRS.is(); -} - -Reference< XResultSet > SAL_CALL KabCommonStatement::executeQuery( - const OUString& sql ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); - - KabResultSet* pResult = new KabResultSet(this); - Reference< XResultSet > xRS = pResult; - OUString aErr; - - m_pParseTree = m_aParser.parseTree(aErr, sql); - if (m_pParseTree == nullptr) - throw SQLException(aErr, *this, aErr, 0, Any()); - - m_aSQLIterator.setParseTree(m_pParseTree); - m_aSQLIterator.traverseAll(); - switch (m_aSQLIterator.getStatementType()) - { - case OSQLStatementType::Select: - if (isTableKnown(pResult)) // FROM which table ? - { - setKabFields(pResult); // SELECT which columns ? - selectAddressees(pResult); // WHERE which condition ? - sortAddressees(pResult); // ORDER BY which columns ? -// To be continued: DISTINCT -// etc... - } - break; - - default: -// To be continued: UPDATE -// DELETE -// etc... - lcl_throwError(STR_QUERY_TOO_COMPLEX); - } - - return xRS; -} - -Reference< XConnection > SAL_CALL KabCommonStatement::getConnection( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); - - // just return our connection here - return m_pConnection; -} - -sal_Int32 SAL_CALL KabCommonStatement::executeUpdate( const OUString& ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); - - // the return values gives information about how many rows are affected by executing the sql statement - return 0; -} - -Any SAL_CALL KabCommonStatement::getWarnings( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); - - return makeAny(m_aLastWarning); -} - -void SAL_CALL KabCommonStatement::clearWarnings( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); - - m_aLastWarning = SQLWarning(); -} - -::cppu::IPropertyArrayHelper* KabCommonStatement::createArrayHelper( ) const -{ - // this properties are defined by the service statement - // they must be in alphabetic order - Sequence< Property > aProps(10); - Property* pProperties = aProps.getArray(); - sal_Int32 nPos = 0; - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME), - PROPERTY_ID_CURSORNAME, cppu::UnoType<OUString>::get(), 0); - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ESCAPEPROCESSING), - PROPERTY_ID_ESCAPEPROCESSING, cppu::UnoType<bool>::get(), 0); - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), - PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), - PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXFIELDSIZE), - PROPERTY_ID_MAXFIELDSIZE, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXROWS), - PROPERTY_ID_MAXROWS, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_QUERYTIMEOUT), - PROPERTY_ID_QUERYTIMEOUT, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), - PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), - PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_USEBOOKMARKS), - PROPERTY_ID_USEBOOKMARKS, cppu::UnoType<bool>::get(), 0); - - return new ::cppu::OPropertyArrayHelper(aProps); -} - -::cppu::IPropertyArrayHelper & KabCommonStatement::getInfoHelper() -{ - return *getArrayHelper(); -} - -sal_Bool KabCommonStatement::convertFastPropertyValue( - Any &, - Any &, - sal_Int32, - const Any&) -{ - bool bConverted = false; - // here we have to try to convert - return bConverted; -} - -void KabCommonStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any&) -{ - // set the value to whatever is necessary - switch (nHandle) - { - case PROPERTY_ID_QUERYTIMEOUT: - case PROPERTY_ID_MAXFIELDSIZE: - case PROPERTY_ID_MAXROWS: - case PROPERTY_ID_CURSORNAME: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - case PROPERTY_ID_FETCHDIRECTION: - case PROPERTY_ID_FETCHSIZE: - case PROPERTY_ID_ESCAPEPROCESSING: - case PROPERTY_ID_USEBOOKMARKS: - default: - ; - } -} - -void KabCommonStatement::getFastPropertyValue(Any&,sal_Int32 nHandle) const -{ - switch (nHandle) - { - case PROPERTY_ID_QUERYTIMEOUT: - case PROPERTY_ID_MAXFIELDSIZE: - case PROPERTY_ID_MAXROWS: - case PROPERTY_ID_CURSORNAME: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - case PROPERTY_ID_FETCHDIRECTION: - case PROPERTY_ID_FETCHSIZE: - case PROPERTY_ID_ESCAPEPROCESSING: - case PROPERTY_ID_USEBOOKMARKS: - default: - ; - } -} - -void SAL_CALL KabCommonStatement::acquire() throw() -{ - KabCommonStatement_BASE::acquire(); -} - -void SAL_CALL KabCommonStatement::release() throw() -{ - KabCommonStatement_BASE::release(); -} - -Reference< css::beans::XPropertySetInfo > SAL_CALL KabCommonStatement::getPropertySetInfo( ) -{ - return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); -} - -KabStatement::KabStatement(KabConnection* _pConnection) - : KabStatement_BASE(_pConnection) -{ -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KStatement.hxx b/connectivity/source/drivers/kab/KStatement.hxx deleted file mode 100644 index 43b0adb9feb0..000000000000 --- a/connectivity/source/drivers/kab/KStatement.hxx +++ /dev/null @@ -1,162 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KSTATEMENT_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KSTATEMENT_HXX - -#include "KConnection.hxx" -#include <list> -#include <connectivity/sqliterator.hxx> -#include <connectivity/sqlparse.hxx> -#include <com/sun/star/sdbc/XStatement.hpp> -#include <com/sun/star/util/XCancellable.hpp> -#include <cppuhelper/compbase.hxx> -#include <cppuhelper/implbase.hxx> -#include <comphelper/proparrhlp.hxx> - -namespace connectivity -{ - namespace kab - { - typedef ::cppu::WeakComponentImplHelper< css::sdbc::XStatement, - css::sdbc::XWarningsSupplier, - css::util::XCancellable, - css::sdbc::XCloseable> KabCommonStatement_BASE; - - - // Class KabCommonStatement - // is a base class for the normal statement and for the prepared statement - - class KabCommonStatement : public cppu::BaseMutex, - public KabCommonStatement_BASE, - public ::cppu::OPropertySetHelper, - public comphelper::OPropertyArrayUsageHelper<KabCommonStatement> - - { - css::sdbc::SQLWarning m_aLastWarning; - - protected: - std::list< OUString> m_aBatchList; - connectivity::OSQLParser m_aParser; - connectivity::OSQLParseTreeIterator m_aSQLIterator; - connectivity::OSQLParseNode* m_pParseTree; - KabConnection* m_pConnection; // The owning Connection object - - protected: - class KabCondition *analyseWhereClause( - const OSQLParseNode *pParseNode) const; - class KabOrder *analyseOrderByClause( - const OSQLParseNode *pParseNode) const; - bool isTableKnown(class KabResultSet *pResult) const; - void setKabFields(class KabResultSet *pResult) const; - void selectAddressees(KabResultSet *pResult) const; - void sortAddressees(KabResultSet *pResult) const; - - // OPropertyArrayUsageHelper - virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const override; - - // OPropertySetHelper - virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; - virtual sal_Bool SAL_CALL convertFastPropertyValue( - css::uno::Any & rConvertedValue, - css::uno::Any & rOldValue, - sal_Int32 nHandle, - const css::uno::Any& rValue) override; - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const css::uno::Any& rValue) override; - virtual void SAL_CALL getFastPropertyValue( - css::uno::Any& rValue, - sal_Int32 nHandle) const override; - using OPropertySetHelper::getFastPropertyValue; - - virtual void resetParameters() const; - virtual void getNextParameter(OUString &rParameter) const; - virtual ~KabCommonStatement() override; - - public: - using KabCommonStatement_BASE::rBHelper; - - explicit KabCommonStatement(KabConnection *_pConnection); - using KabCommonStatement_BASE::operator css::uno::Reference< css::uno::XInterface >; - - // OComponentHelper - using KabCommonStatement_BASE::disposing; - - // XInterface - virtual void SAL_CALL release() throw() override; - virtual void SAL_CALL acquire() throw() override; - virtual css::uno::Any SAL_CALL queryInterface( - const css::uno::Type & rType - ) override; - - // XTypeProvider - virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( - ) override; - - // XPropertySet - virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( - ) override; - - // XStatement - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery( - const OUString& sql ) override; - virtual sal_Int32 SAL_CALL executeUpdate( - const OUString& sql ) override; - virtual sal_Bool SAL_CALL execute( - const OUString& sql ) override; - virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( - ) override; - - // XWarningsSupplier - virtual css::uno::Any SAL_CALL getWarnings( - ) override; - virtual void SAL_CALL clearWarnings( - ) override; - - // XCancellable - virtual void SAL_CALL cancel( - ) override; - - // XCloseable - virtual void SAL_CALL close( - ) override; - }; - - - // Class KabStatement - - typedef ::cppu::ImplInheritanceHelper< - KabCommonStatement, css::lang::XServiceInfo > KabStatement_BASE; - - class KabStatement : public KabStatement_BASE - { - protected: - virtual ~KabStatement() override { } - - public: - explicit KabStatement(KabConnection* _pConnection); - DECLARE_SERVICE_INFO(); - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KSTATEMENT_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KTable.cxx b/connectivity/source/drivers/kab/KTable.cxx deleted file mode 100644 index ceac4b08c93c..000000000000 --- a/connectivity/source/drivers/kab/KTable.cxx +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "KTable.hxx" -#include "KTables.hxx" -#include "KColumns.hxx" -#include "KCatalog.hxx" - -using namespace connectivity::kab; -using namespace connectivity; -using namespace ::comphelper; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; - - -KabTable::KabTable( sdbcx::OCollection* pTables, - KabConnection* pConnection, - const OUString& Name, - const OUString& Type, - const OUString& Description , - const OUString& SchemaName, - const OUString& CatalogName - ) : KabTable_TYPEDEF(pTables,true, - Name, - Type, - Description, - SchemaName, - CatalogName), - m_pConnection(pConnection) -{ - construct(); -} - -void KabTable::refreshColumns() -{ - TStringVector aVector; - - if (!isNew()) - { - Reference< XResultSet > xResult = - m_pConnection->getMetaData()->getColumns( - Any(), m_SchemaName, m_Name, "%"); - - if (xResult.is()) - { - Reference< XRow > xRow(xResult, UNO_QUERY); - while (xResult->next()) - { - aVector.push_back(xRow->getString(4)); - } - } - } - - if (m_pColumns) - m_pColumns->reFill(aVector); - else - m_pColumns = new KabColumns(this,m_aMutex,aVector); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KTable.hxx b/connectivity/source/drivers/kab/KTable.hxx deleted file mode 100644 index 706715126f02..000000000000 --- a/connectivity/source/drivers/kab/KTable.hxx +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KTABLE_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KTABLE_HXX - -#include "KConnection.hxx" -#include <connectivity/sdbcx/VTable.hxx> - -namespace connectivity -{ - namespace kab - { - typedef connectivity::sdbcx::OTable KabTable_TYPEDEF; - - class KabTable : public KabTable_TYPEDEF - { - css::uno::Reference< css::sdbc::XDatabaseMetaData > m_xMetaData; - KabConnection* m_pConnection; - - public: - KabTable( sdbcx::OCollection* pTables, - KabConnection* pConnection, - const OUString& Name, - const OUString& Type, - const OUString& Description = OUString(), - const OUString& SchemaName = OUString(), - const OUString& CatalogName = OUString() - ); - - KabConnection* getConnection() { return m_pConnection;} - - virtual void refreshColumns() override; - - OUString getTableName() const { return m_Name; } - OUString getSchema() const { return m_SchemaName; } - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KTABLE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KTables.cxx b/connectivity/source/drivers/kab/KTables.cxx deleted file mode 100644 index d84601f44d89..000000000000 --- a/connectivity/source/drivers/kab/KTables.cxx +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "KTables.hxx" -#include "KTable.hxx" -#include "KCatalog.hxx" -#include "KConnection.hxx" -#include <comphelper/types.hxx> - -using namespace connectivity::kab; -using namespace connectivity; -using namespace ::comphelper; -using namespace ::cppu; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; - -sdbcx::ObjectType KabTables::createObject(const OUString& _rName) -{ - OUString aName,aSchema; - aSchema = "%"; - aName = _rName; - - Sequence< OUString > aTypes { "%" }; - - Reference< XResultSet > xResult = m_xMetaData->getTables(Any(), aSchema, aName, aTypes); - - sdbcx::ObjectType xRet = nullptr; - if (xResult.is()) - { - Reference< XRow > xRow(xResult, UNO_QUERY); - if (xResult->next()) // there can be only one table with this name - { - KabTable* pRet = new KabTable( - this, - static_cast<KabCatalog&>(m_rParent).getConnection(), - aName, - xRow->getString(4), - xRow->getString(5), - ""); - xRet = pRet; - } - } - ::comphelper::disposeComponent(xResult); - - return xRet; -} - -void KabTables::impl_refresh( ) -{ - static_cast<KabCatalog&>(m_rParent).refreshTables(); -} - -void KabTables::disposing() -{ -m_xMetaData.clear(); - OCollection::disposing(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/KTables.hxx b/connectivity/source/drivers/kab/KTables.hxx deleted file mode 100644 index 564ca3faba52..000000000000 --- a/connectivity/source/drivers/kab/KTables.hxx +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KTABLES_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KTABLES_HXX - -#include <connectivity/sdbcx/VCollection.hxx> -#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> - -namespace connectivity -{ - namespace kab - { - class KabTables : public sdbcx::OCollection - { - css::uno::Reference< css::sdbc::XDatabaseMetaData > m_xMetaData; - - protected: - virtual sdbcx::ObjectType createObject(const OUString& _rName) override; - virtual void impl_refresh() override; - - public: - KabTables( - const css::uno::Reference< css::sdbc::XDatabaseMetaData >& _rMetaData, - ::cppu::OWeakObject& _rParent, - ::osl::Mutex& _rMutex, - const TStringVector &_rVector) - : sdbcx::OCollection(_rParent,true,_rMutex,_rVector), - m_xMetaData(_rMetaData) - { } - - virtual void SAL_CALL disposing() override; - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KTABLES_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/kcondition.cxx b/connectivity/source/drivers/kab/kcondition.cxx deleted file mode 100644 index 3721585e3109..000000000000 --- a/connectivity/source/drivers/kab/kcondition.cxx +++ /dev/null @@ -1,221 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "kcondition.hxx" -#include "kfields.hxx" -#include <connectivity/CommonTools.hxx> - -using namespace ::connectivity::kab; -using namespace ::com::sun::star::sdbc; - -KabCondition::~KabCondition() -{ -} - -KabConditionConstant::KabConditionConstant(const bool bValue) - : KabCondition(), - m_bValue(bValue) -{ -} - -bool KabConditionConstant::isAlwaysTrue() const -{ - return m_bValue; -} - -bool KabConditionConstant::isAlwaysFalse() const -{ - return !m_bValue; -} - -bool KabConditionConstant::eval(const ::KABC::Addressee &) const -{ - return m_bValue; -} - -KabConditionColumn::KabConditionColumn(const OUString &sColumnName) - : KabCondition(), - m_nFieldNumber(findKabField(sColumnName)) -{ -} - -bool KabConditionColumn::isAlwaysTrue() const -{ - // Sometimes true, sometimes false - return false; -} - -bool KabConditionColumn::isAlwaysFalse() const -{ - // Sometimes true, sometimes false - return false; -} - -KabConditionNull::KabConditionNull(const OUString &sColumnName) - : KabConditionColumn(sColumnName) -{ -} - -bool KabConditionNull::eval(const ::KABC::Addressee &aAddressee) const -{ - QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber); - - return aQtName.isNull(); -// KDE address book currently does not use nullptr values. -// But it might do it someday -} - -KabConditionNotNull::KabConditionNotNull(const OUString &sColumnName) - : KabConditionColumn(sColumnName) -{ -} - -bool KabConditionNotNull::eval(const ::KABC::Addressee &aAddressee) const -{ - QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber); - - return !aQtName.isNull(); -// KDE address book currently does not use nullptr values. -// But it might do it someday -} - -KabConditionCompare::KabConditionCompare(const OUString &sColumnName, const OUString &sMatchString) - : KabConditionColumn(sColumnName), - m_sMatchString(sMatchString) -{ -} - -KabConditionEqual::KabConditionEqual(const OUString &sColumnName, const OUString &sMatchString) - : KabConditionCompare(sColumnName, sMatchString) -{ -} - -bool KabConditionEqual::eval(const ::KABC::Addressee &aAddressee) const -{ - QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber); -// Timestamps should not be compared according to their string value -// The syntax for such queries should be like -// {ts '2004-03-29 12:55:00.000000'} -// They should also support operators like '<' or '>=' - - if (aQtName.isNull()) return false; - - OUString sValue(reinterpret_cast<const sal_Unicode *>(aQtName.ucs2())); - return sValue == m_sMatchString; -} - -KabConditionDifferent::KabConditionDifferent(const OUString &sColumnName, const OUString &sMatchString) - : KabConditionCompare(sColumnName, sMatchString) -{ -} - -bool KabConditionDifferent::eval(const ::KABC::Addressee &aAddressee) const -{ - QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber); - - if (aQtName.isNull()) return false; - - OUString sValue(reinterpret_cast<const sal_Unicode *>(aQtName.ucs2())); - return sValue != m_sMatchString; -} - -KabConditionSimilar::KabConditionSimilar(const OUString &sColumnName, const OUString &sMatchString) - : KabConditionCompare(sColumnName, sMatchString) -{ -} - -bool KabConditionSimilar::eval(const ::KABC::Addressee &aAddressee) const -{ - QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber); - - if (aQtName.isNull()) return false; - - OUString sValue(reinterpret_cast<const sal_Unicode *>(aQtName.ucs2())); - return match(m_sMatchString, sValue, '\0'); -} - -KabConditionBoolean::KabConditionBoolean(KabCondition *pLeft, KabCondition *pRight) - : KabCondition(), - m_pLeft(pLeft), - m_pRight(pRight) -{ -} - -KabConditionBoolean::~KabConditionBoolean() -{ - delete m_pLeft; - delete m_pRight; -} - -KabConditionOr::KabConditionOr(KabCondition *pLeft, KabCondition *pRight) - : KabConditionBoolean(pLeft, pRight) -{ -} - -bool KabConditionOr::isAlwaysTrue() const -{ - return m_pLeft->isAlwaysTrue() || m_pRight->isAlwaysTrue(); -} - -bool KabConditionOr::isAlwaysFalse() const -{ - return m_pLeft->isAlwaysFalse() && m_pRight->isAlwaysFalse(); -} - -bool KabConditionOr::eval(const ::KABC::Addressee &aAddressee) const -{ - // We avoid evaluating terms as much as we can - if (m_pLeft->isAlwaysTrue() || m_pRight->isAlwaysTrue()) return true; - if (m_pLeft->isAlwaysFalse() && m_pRight->isAlwaysFalse()) return false; - - if (m_pLeft->eval(aAddressee)) return true; - if (m_pRight->eval(aAddressee)) return true; - - return false; -} - -KabConditionAnd::KabConditionAnd(KabCondition *pLeft, KabCondition *pRight) - : KabConditionBoolean(pLeft, pRight) -{ -} - -bool KabConditionAnd::isAlwaysTrue() const -{ - return m_pLeft->isAlwaysTrue() && m_pRight->isAlwaysTrue(); -} - -bool KabConditionAnd::isAlwaysFalse() const -{ - return m_pLeft->isAlwaysFalse() || m_pRight->isAlwaysFalse(); -} - -bool KabConditionAnd::eval(const ::KABC::Addressee &aAddressee) const -{ - // We avoid evaluating terms as much as we can - if (m_pLeft->isAlwaysFalse() || m_pRight->isAlwaysFalse()) return false; - if (m_pLeft->isAlwaysTrue() && m_pRight->isAlwaysTrue()) return true; - - if (!m_pLeft->eval(aAddressee)) return false; - if (!m_pRight->eval(aAddressee)) return false; - - return true; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/kcondition.hxx b/connectivity/source/drivers/kab/kcondition.hxx deleted file mode 100644 index 5225ffa573b4..000000000000 --- a/connectivity/source/drivers/kab/kcondition.hxx +++ /dev/null @@ -1,154 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCONDITION_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCONDITION_HXX - -#include <comphelper/types.hxx> -#include <shell/kde_headers.h> -#include <connectivity/dbexception.hxx> - -namespace connectivity -{ - namespace kab - { - -class KabCondition -{ - public: - virtual ~KabCondition(); - virtual bool isAlwaysTrue() const = 0; - virtual bool isAlwaysFalse() const = 0; - virtual bool eval(const ::KABC::Addressee &aAddressee) const = 0; -}; - -class KabConditionConstant : public KabCondition -{ - protected: - bool m_bValue; - - public: - explicit KabConditionConstant(const bool bValue); - virtual bool isAlwaysTrue() const override; - virtual bool isAlwaysFalse() const override; - virtual bool eval(const ::KABC::Addressee &aAddressee) const override; -}; - -class KabConditionColumn : public KabCondition -{ - protected: - sal_Int32 m_nFieldNumber; - - QString value(const ::KABC::Addressee &aAddressee) const; - - public: - explicit KabConditionColumn( - const OUString &sColumnName); - virtual bool isAlwaysTrue() const override; - virtual bool isAlwaysFalse() const override; -}; - -class KabConditionNull : public KabConditionColumn -{ - public: - explicit KabConditionNull( - const OUString &sColumnName); - virtual bool eval(const ::KABC::Addressee &aAddressee) const override; -}; - -class KabConditionNotNull : public KabConditionColumn -{ - public: - explicit KabConditionNotNull( - const OUString &sColumnName); - virtual bool eval(const ::KABC::Addressee &aAddressee) const override; -}; - -class KabConditionCompare : public KabConditionColumn -{ - protected: - const OUString m_sMatchString; - - public: - KabConditionCompare( - const OUString &sColumnName, - const OUString &sMatchString); -}; - -class KabConditionEqual : public KabConditionCompare -{ - public: - KabConditionEqual( - const OUString &sColumnName, - const OUString &sMatchString); - virtual bool eval(const ::KABC::Addressee &aAddressee) const override; -}; - -class KabConditionDifferent : public KabConditionCompare -{ - public: - KabConditionDifferent( - const OUString &sColumnName, - const OUString &sMatchString); - virtual bool eval(const ::KABC::Addressee &aAddressee) const override; -}; - -class KabConditionSimilar : public KabConditionCompare -{ - public: - KabConditionSimilar( - const OUString &sColumnName, - const OUString &sMatchString); - virtual bool eval(const ::KABC::Addressee &aAddressee) const override; -}; - -class KabConditionBoolean : public KabCondition -{ - protected: - KabCondition *m_pLeft, *m_pRight; - - public: - KabConditionBoolean(KabCondition *pLeft, KabCondition *pRight); - virtual ~KabConditionBoolean() override; -}; - -class KabConditionOr : public KabConditionBoolean -{ - public: - KabConditionOr(KabCondition *pLeft, KabCondition *pRight); - virtual bool isAlwaysTrue() const override; - virtual bool isAlwaysFalse() const override; - virtual bool eval(const ::KABC::Addressee &aAddressee) const override; -}; - -class KabConditionAnd : public KabConditionBoolean -{ - public: - KabConditionAnd(KabCondition *pLeft, KabCondition *pRight); - virtual bool isAlwaysTrue() const override; - virtual bool isAlwaysFalse() const override; - virtual bool eval(const ::KABC::Addressee &addressee) const override; -}; - - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCONDITION_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/kfields.cxx b/connectivity/source/drivers/kab/kfields.cxx deleted file mode 100644 index e86ea64efa4d..000000000000 --- a/connectivity/source/drivers/kab/kfields.cxx +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <sal/config.h> - -#include <osl/diagnose.h> - -#include "kfields.hxx" -#include "resource/common_res.hrc" -#include "resource/sharedresources.hxx" - -using namespace ::connectivity::kab; -using namespace ::com::sun::star::sdbc; - -namespace connectivity -{ - namespace kab - { - -// return the value of a KDE address book field, given an addressee and a field number -QString valueOfKabField(const ::KABC::Addressee &aAddressee, sal_Int32 nFieldNumber) -{ - switch (nFieldNumber) - { - case KAB_FIELD_REVISION: - return aAddressee.revision().toString("yyyy-MM-dd hh:mm:ss"); - default: - ::KABC::Field::List aFields = ::KABC::Field::allFields(); - return aFields[nFieldNumber - KAB_DATA_FIELDS]->value(aAddressee); - } -} - -// search the KDE address book field number of a given column name -sal_uInt32 findKabField(const OUString& columnName) -{ - QString aQtName; - OUString aName; - - aQtName = KABC::Addressee::revisionLabel(); - aName = OUString(reinterpret_cast<const sal_Unicode *>(aQtName.ucs2())); - if (columnName == aName) - return KAB_FIELD_REVISION; - - ::KABC::Field::List aFields = ::KABC::Field::allFields(); - ::KABC::Field::List::const_iterator aField; - sal_uInt32 nResult; - - for ( aField = aFields.begin(), nResult = KAB_DATA_FIELDS; - aField != aFields.end(); - ++aField, ++nResult) - { - aQtName = (*aField)->label(); - aName = OUString(reinterpret_cast<const sal_Unicode *>(aQtName.ucs2())); - - if (columnName == aName) - return nResult; - } - - ::connectivity::SharedResources aResources; - const OUString sError( aResources.getResourceStringWithSubstitution( - STR_INVALID_COLUMNNAME, - "$columnname$",columnName - ) ); - ::dbtools::throwGenericSQLException(sError,nullptr); - // Unreachable: - OSL_ASSERT(false); - return 0; -} - - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/kfields.hxx b/connectivity/source/drivers/kab/kfields.hxx deleted file mode 100644 index 02121deaf5c9..000000000000 --- a/connectivity/source/drivers/kab/kfields.hxx +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KFIELDS_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KFIELDS_HXX - -#include <shell/kde_headers.h> -#include <connectivity/dbexception.hxx> -#include <rtl/ustring.hxx> - -#define KAB_FIELD_REVISION 0 -#define KAB_DATA_FIELDS 1 - -namespace connectivity -{ - namespace kab - { - QString valueOfKabField(const ::KABC::Addressee &aAddressee, sal_Int32 nFieldNumber); - sal_uInt32 findKabField(const OUString& columnName); - } -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/korder.cxx b/connectivity/source/drivers/kab/korder.cxx deleted file mode 100644 index 6ff1f0c8915a..000000000000 --- a/connectivity/source/drivers/kab/korder.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "korder.hxx" -#include "kfields.hxx" - -using namespace ::connectivity::kab; - -KabOrder::~KabOrder() -{ -} - -KabSimpleOrder::KabSimpleOrder(OUString &sColumnName, bool bAscending) - : KabOrder(), - m_nFieldNumber(findKabField(sColumnName)), - m_bAscending(bAscending) -{ -} - -sal_Int32 KabSimpleOrder::compare(const ::KABC::Addressee &aAddressee1, const ::KABC::Addressee &aAddressee2) const -{ - sal_Int32 result; - - result = QString::compare( - valueOfKabField(aAddressee1, m_nFieldNumber), - valueOfKabField(aAddressee2, m_nFieldNumber)); -// Timestamps should be compared differently than with their string value - - if (!m_bAscending) result = -result; - - return result; -} - -KabComplexOrder::KabComplexOrder() - : KabOrder(), - m_aOrders() -{ -} - -KabComplexOrder::~KabComplexOrder() -{ - for (auto p: m_aOrders) - delete p; -} - -void KabComplexOrder::addOrder(KabOrder *pOrder) -{ - m_aOrders.push_back(pOrder); -} - -sal_Int32 KabComplexOrder::compare(const ::KABC::Addressee &aAddressee1, const ::KABC::Addressee &aAddressee2) const -{ - for (auto p: m_aOrders) - { - sal_Int32 result = p->compare(aAddressee1, aAddressee2); - - if (result) return result; - } - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/korder.hxx b/connectivity/source/drivers/kab/korder.hxx deleted file mode 100644 index 000d3f782fdc..000000000000 --- a/connectivity/source/drivers/kab/korder.hxx +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KORDER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KORDER_HXX - -#include <rtl/ustring.hxx> -#include <shell/kde_headers.h> - -#include <vector> - -namespace connectivity -{ - namespace kab - { - class KabOrder - { - public: - virtual ~KabOrder(); - - virtual sal_Int32 compare(const ::KABC::Addressee &aAddressee1, const ::KABC::Addressee &aAddressee2) const = 0; - }; - - class KabSimpleOrder : public KabOrder - { - sal_Int32 m_nFieldNumber; - bool m_bAscending; - - QString value(const ::KABC::Addressee &aAddressee) const; - public: - KabSimpleOrder(OUString &sColumnName, bool bAscending); - - virtual sal_Int32 compare(const ::KABC::Addressee &aAddressee1, const ::KABC::Addressee &aAddressee2) const override; - }; - - class KabComplexOrder : public KabOrder - { - std::vector<KabOrder *> m_aOrders; - - public: - KabComplexOrder(); - virtual ~KabComplexOrder() override; - - void addOrder(KabOrder *pOrder); - virtual sal_Int32 compare(const ::KABC::Addressee &aAddressee1, const ::KABC::Addressee &aAddressee2) const override; - }; - } -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/kab/tdeab1.component b/connectivity/source/drivers/kab/tdeab1.component deleted file mode 100644 index fe82d6548d09..000000000000 --- a/connectivity/source/drivers/kab/tdeab1.component +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * 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/. - * ---> -<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="tdeab" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.sdbc.tdeab.Driver"> - <service name="com.sun.star.sdbc.Driver"/> - </implementation> -</component> diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk index 7eb55fb05375..2b9663a7cc93 100644 --- a/cui/Library_cui.mk +++ b/cui/Library_cui.mk @@ -21,7 +21,6 @@ $(eval $(call gb_Library_set_precompiled_header,cui,$(SRCDIR)/cui/inc/pch/precom $(eval $(call gb_Library_add_defs,cui,\ $(if $(filter TRUE,$(ENABLE_GTK)),-DENABLE_GTK) \ - $(if $(filter TRUE,$(ENABLE_TDE)),-DENABLE_TDE) \ $(if $(filter TRUE,$(ENABLE_KDE4)),-DENABLE_KDE4) \ )) diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx index 8f7c9493915e..4e1bf3c5635a 100644 --- a/cui/source/options/optgdlg.cxx +++ b/cui/source/options/optgdlg.cxx @@ -210,14 +210,6 @@ namespace return OUString(); #endif } - else if ( rDesktopEnvironment.equalsIgnoreAsciiCase("tde") ) - { - #if ENABLE_TDE - return OUString("com.sun.star.ui.dialogs.TDEFilePicker"); - #else - return OUString(); - #endif - } #if defined(_WIN32) return OUString("com.sun.star.ui.dialogs.SystemFilePicker"); #elif defined MACOSX diff --git a/desktop/Pagein_common.mk b/desktop/Pagein_common.mk index fe42ca7f5f50..ca5873db7903 100644 --- a/desktop/Pagein_common.mk +++ b/desktop/Pagein_common.mk @@ -29,7 +29,6 @@ $(eval $(call gb_Pagein_add_objects,common,\ configmgr \ vclplug_gen \ $(if $(findstring TRUE,$(ENABLE_GTK)),vclplug_gtk) \ - $(if $(findstring TRUE,$(ENABLE_TDE)),vclplug_tde) \ basegfx \ sot \ xmlscript \ diff --git a/include/shell/kde_headers.h b/include/shell/kde_headers.h deleted file mode 100644 index 9b4eeac8d151..000000000000 --- a/include/shell/kde_headers.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_SHELL_KDE_HEADERS_H -#define INCLUDED_SHELL_KDE_HEADERS_H - -#include <config_vclplug.h> - -#if ENABLE_TDE - -#include <shell/tde_headers.h> - -#else // ENABLE_TDE - -/* ********* Suppress warnings if needed */ -#include <sal/config.h> - -#include <cstddef> - -#if defined __GNUC__ -#pragma GCC system_header -#endif - -/* ********* Qt headers */ -#include <qaccessible.h> -#include <qcheckbox.h> -#include <qcombobox.h> -#include <qfont.h> -#include <qframe.h> -#include <qlineedit.h> -#include <qlistview.h> -#include <qmainwindow.h> -#include <qmenudata.h> -#include <qpaintdevice.h> -#include <qpainter.h> -#include <qpushbutton.h> -#include <qradiobutton.h> -#include <qrangecontrol.h> -#include <qstring.h> -#include <qtabbar.h> -#include <qtabwidget.h> -#include <qtoolbar.h> -#include <qtoolbutton.h> -#include <qwidget.h> -#include <qprogressbar.h> - -/* ********* See hack on top of this file */ -#undef Region - - -/* ********* KDE base headers */ -#include <kaboutdata.h> -#include <kapplication.h> -#include <kcmdlineargs.h> -#include <kconfig.h> -#include <kdeversion.h> -#include <kemailsettings.h> -#include <kglobal.h> -#include <kglobalsettings.h> -#include <klocale.h> -#include <kmainwindow.h> -#include <kmenubar.h> -#include <kprotocolmanager.h> -#include <kstartupinfo.h> -#include <kstyle.h> - - -/* ********* KDE address book connectivity headers */ -#include <kabc/addressbook.h> -#include <kabc/addressee.h> -#include <kabc/field.h> -#include <kabc/stdaddressbook.h> - -#endif // ENABLE_TDE - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/shell/tde_defines.h b/include/shell/tde_defines.h deleted file mode 100644 index 0bf40fe407dd..000000000000 --- a/include/shell/tde_defines.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - */ -/* - * Copyright (C) 2012, Timothy Pearson <kb9vqf@pearsoncomputing.net> - */ - -#ifndef INCLUDED_SHELL_TDE_DEFINES_H -#define INCLUDED_SHELL_TDE_DEFINES_H - -#define QObject TQObject -#define QWidget TQWidget -#define QVBox TQVBox -#define QHBox TQHBox -#define QGrid TQGrid -#define QString TQString -#define QStringList TQStringList -#define QCustomEvent TQCustomEvent -#define QMutex TQMutex -#define QEvent TQEvent -#define QFont TQFont -#define QDateTime TQDateTime -#define QThread TQThread -#define QStyle TQStyle -#define QApplication TQApplication -#define QRect TQRect -#define QProgressBar TQProgressBar -#define QPopupMenu TQPopupMenu -#define QMenuBar TQMenuBar -#define QToolButton TQToolButton -#define QToolBar TQToolBar -#define QScrollBar TQScrollBar -#define QListView TQListView -#define QSpinWidget TQSpinWidget -#define QScrollBar TQScrollBar -#define QLineEdit TQLineEdit -#define QComboBox TQComboBox -#define QCheckBox TQCheckBox -#define QRadioButton TQRadioButton -#define QPushButton TQPushButton -#define QPainter TQPainter -#define QResizeEvent TQResizeEvent -#define QShowEvent TQShowEvent -#define QPoint TQPoint -#define QDialog TQDialog -#define QFile TQFile -#define QLabel TQLabel -#define QObjectList TQObjectList -#define QCString TQCString -#define QRegExp TQRegExp -#define QSessionManager TQSessionManager -#define QPaintDevice TQPaintDevice -#define QTextIStream TQTextIStream -#define QTextStream TQTextStream -#define QMutexLocker TQMutexLocker -#define QValueList TQValueList -#define QTab TQTab -#define QTabBar TQTabBar -#define QTabWidget TQTabWidget -#define QMainWindow TQMainWindow -#define QPixmap TQPixmap -#define QColorGroup TQColorGroup -#define QStyleOption TQStyleOption -#define QSize TQSize -#define QMenuItem TQMenuItem -#define QFontInfo TQFontInfo - -#define qSwap tqSwap -#define qt_cast tqt_cast -#define qt_xdisplay tqt_xdisplay -#define qVersion tqVersion - -#define KAboutData TDEAboutData -#define KApplication TDEApplication -#define KCmdLineArgs TDECmdLineArgs -#define KConfig TDEConfig -#define KGlobal TDEGlobal -#define KGlobalSettings TDEGlobalSettings -#define KMainWindow TDEMainWindow -#define KStartupInfo TDEStartupInfo -#define KStyle TDEStyle -#define KToolBar TDEToolBar - -#define drawKStylePrimitive drawTDEStylePrimitive - -#define KIO TDEIO -#define KABC TDEABC - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/shell/tde_headers.h b/include/shell/tde_headers.h deleted file mode 100644 index c537ea381988..000000000000 --- a/include/shell/tde_headers.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - */ -/* - * Copyright (C) 2012, Timothy Pearson <kb9vqf@pearsoncomputing.net> - */ - -#ifndef INCLUDED_SHELL_TDE_HEADERS_H -#define INCLUDED_SHELL_TDE_HEADERS_H - -/* ********* Suppress warnings if needed */ -#include <sal/config.h> - -#include <cstddef> - -#if defined __GNUC__ -#pragma GCC system_header -#endif - - -/* ********* Hack, but needed because of conflicting types... */ -#define Region TQtXRegion - - -/* ********* TQt headers */ -#include <tqaccessible.h> -#include <tqcheckbox.h> -#include <tqcombobox.h> -#include <tqfont.h> -#include <tqframe.h> -#include <tqlineedit.h> -#include <tqlistview.h> -#include <tqmainwindow.h> -#include <tqmenudata.h> -#include <tqpaintdevice.h> -#include <tqpainter.h> -#include <tqpushbutton.h> -#include <tqradiobutton.h> -#include <tqrangecontrol.h> -#include <tqstring.h> -#include <tqtabbar.h> -#include <tqtabwidget.h> -#include <tqtoolbar.h> -#include <tqtoolbutton.h> -#include <tqwidget.h> -#include <tqprogressbar.h> - -/* ********* See hack on top of this file */ -#undef Region - - -/* ********* TDE base headers */ -#include <tdeaboutdata.h> -#include <tdeapplication.h> -#include <tdecmdlineargs.h> -#include <tdeconfig.h> -#include <tdeversion.h> -#include <tdeemailsettings.h> -#include <tdeglobal.h> -#include <tdeglobalsettings.h> -#include <tdelocale.h> -#include <tdemainwindow.h> -#include <tdemenubar.h> -#include <tdeprotocolmanager.h> -#include <tdestartupinfo.h> -#include <tdestyle.h> - - -/* ********* TDE address book connectivity headers */ -#include <tdeabc/addressbook.h> -#include <tdeabc/addressee.h> -#include <tdeabc/field.h> -#include <tdeabc/stdaddressbook.h> - -#include <shell/tde_defines.h> - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/source/gRun.sh b/l10ntools/source/gRun.sh index 65ca9badc277..496cbac4d40c 100755 --- a/l10ntools/source/gRun.sh +++ b/l10ntools/source/gRun.sh @@ -165,8 +165,6 @@ ${MYCMD} --files scp2/source/python/module_python_librelogo.ulf ${MYCMD} --files scp2/source/quickstart/module_quickstart.ulf -${MYCMD} --files scp2/source/tde/module_tde.ulf - ${MYCMD} --files scp2/source/winexplorerext/module_winexplorerext.ulf ${MYCMD} --base scp2/source/writer --files folderitem_writer.ulf module_writer.ulf registryitem_writer.ulf @@ -537,8 +535,6 @@ ${MYCMD} --files connectivity/registry/odbc/org/openoffice/Office/DataAccess/Dri ${MYCMD} --files connectivity/registry/postgresql/org/openoffice/Office/DataAccess/Drivers.xcu -${MYCMD} --files connectivity/registry/tdeab/org/openoffice/Office/DataAccess/Drivers.xcu - ${MYCMD} --files dictionaries/af_ZA/dictionaries.xcu ${MYCMD} --files dictionaries/an_ES/dictionaries.xcu diff --git a/postprocess/CustomTarget_registry.mk b/postprocess/CustomTarget_registry.mk index 75fb4d2744be..294f9de9400f 100644 --- a/postprocess/CustomTarget_registry.mk +++ b/postprocess/CustomTarget_registry.mk @@ -344,9 +344,6 @@ postprocess_FILES_main += \ $(call gb_XcuModuleTarget_get_target,connectivity/registry/firebird)/org/openoffice/Office/DataAccess/Drivers-firebird.xcu postprocess_DRIVERS += firebird_sdbc endif -ifeq ($(ENABLE_TDEAB),TRUE) -postprocess_FILES_main += $(call gb_XcuModuleTarget_get_target,connectivity/registry/tdeab)/org/openoffice/Office/DataAccess/Drivers-tdeab.xcu -endif ifneq (,$(SYSTEM_LIBEXTTEXTCAT_DATA)) postprocess_FILES_main += $(postprocess_MOD)/org/openoffice/Office/Paths-externallibexttextcatdata.xcu diff --git a/postprocess/Rdb_services.mk b/postprocess/Rdb_services.mk index cd7a10cadd64..96b8680cced5 100644 --- a/postprocess/Rdb_services.mk +++ b/postprocess/Rdb_services.mk @@ -221,9 +221,6 @@ $(eval $(call gb_Rdb_add_components,services,\ $(if $(ENABLE_OPENGL_TRANSITIONS), \ slideshow/source/engine/opengl/ogltrans \ ) \ - $(if $(ENABLE_TDE), \ - shell/source/backends/kdebe/tdebe1 \ - ) \ $(if $(ENABLE_JAVA), \ xmerge/source/bridge/XMergeBridge \ scripting/java/ScriptFramework \ @@ -263,9 +260,6 @@ $(eval $(call gb_Rdb_add_components,services,\ $(if $(filter MACOSX,$(OS)), \ connectivity/source/drivers/macab/macab1 \ ) \ - $(if $(ENABLE_TDEAB), \ - connectivity/source/drivers/kab/tdeab1 \ - ) \ $(if $(ENABLE_JAVA), \ connectivity/source/drivers/hsqldb/hsqldb \ connectivity/source/drivers/jdbc/jdbc \ diff --git a/scp2/AutoInstall.mk b/scp2/AutoInstall.mk index 3c15f888584b..7c9d6c4538bd 100644 --- a/scp2/AutoInstall.mk +++ b/scp2/AutoInstall.mk @@ -45,7 +45,6 @@ $(eval $(call gb_AutoInstall_add_module,pdfimport,LIBO_LIB_FILE,LIBO_EXECUTABLE, $(eval $(call gb_AutoInstall_add_module,quickstart,,LIBO_EXECUTABLE)) $(eval $(call gb_AutoInstall_add_module,reportbuilder,LIBO_LIB_FILE,,LIBO_JAR_FILE,PACKAGE_FILELIST)) $(eval $(call gb_AutoInstall_add_module,sdk,,SDK_EXECUTABLE,,SDK_PACKAGE_FILELIST)) -$(eval $(call gb_AutoInstall_add_module,tde,LIBO_LIB_FILE,LIBO_EXECUTABLE)) $(eval $(call gb_AutoInstall_add_module,ure,URE_PRIVATE_LIB,URE_EXECUTABLE,URE_JAR_FILE,PACKAGE_FILELIST)) $(eval $(call gb_AutoInstall_add_module,winexplorerextbinarytable,LIBO_LIB_FILE_BINARYTABLE)) $(eval $(call gb_AutoInstall_add_module,winexplorerext,SHLXTHDL_LIB_FILE)) diff --git a/scp2/InstallModule_tde.mk b/scp2/InstallModule_tde.mk deleted file mode 100644 index 0e5dae6a2ff5..000000000000 --- a/scp2/InstallModule_tde.mk +++ /dev/null @@ -1,18 +0,0 @@ -# -*- 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_InstallModule_InstallModule,scp2/tde)) - -$(eval $(call gb_InstallModule_use_auto_install_libs,scp2/tde,tde)) - -$(eval $(call gb_InstallModule_add_localized_scpfiles,scp2/tde,\ - scp2/source/tde/module_tde \ -)) - -# vim: set shiftwidth=4 tabstop=4 noexpandtab: diff --git a/scp2/InstallScript_setup_osl.mk b/scp2/InstallScript_setup_osl.mk index 862db6190b8f..63121d2cdc75 100644 --- a/scp2/InstallScript_setup_osl.mk +++ b/scp2/InstallScript_setup_osl.mk @@ -41,9 +41,6 @@ $(eval $(call gb_InstallScript_use_modules,setup_osl,\ $(if $(filter TRUE,$(ENABLE_ONLINE_UPDATE)),\ scp2/onlineupdate \ ) \ - $(if $(filter TRUE,$(ENABLE_TDE)),\ - scp2/tde \ - ) \ )) # vim: set shiftwidth=4 tabstop=4 noexpandtab: diff --git a/scp2/Module_scp2.mk b/scp2/Module_scp2.mk index f94966bb74a7..f2bc6f45c3c4 100644 --- a/scp2/Module_scp2.mk +++ b/scp2/Module_scp2.mk @@ -42,9 +42,6 @@ $(eval $(call gb_Module_add_targets,scp2,\ $(if $(filter TRUE,$(ENABLE_KDE4)),\ InstallModule_kde \ ) \ - $(if $(filter TRUE,$(ENABLE_TDE)),\ - InstallModule_tde \ - ) \ )) # vim: set shiftwidth=4 tabstop=4 noexpandtab: diff --git a/scp2/source/tde/module_tde.scp b/scp2/source/tde/module_tde.scp deleted file mode 100644 index 24725de25303..000000000000 --- a/scp2/source/tde/module_tde.scp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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/. - */ -/* - * Copyright (C) 2012, Timothy Pearson <kb9vqf@pearsoncomputing.net> - */ - -#include "macros.inc" - -#include "AutoInstall/tde" - -Module gid_Module_Optional_Tde - ParentID = gid_Module_Optional; - Default = YES; - PackageInfo = "packinfo_office.txt"; - MOD_NAME_DESC(MODULE_OPTIONAL_TDE); - Styles = (); - Files = (auto_tde_ALL); -End - diff --git a/scp2/source/tde/module_tde.ulf b/scp2/source/tde/module_tde.ulf deleted file mode 100644 index ba230d28386f..000000000000 --- a/scp2/source/tde/module_tde.ulf +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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/. - */ -/* - * Copyright (C) 2012, Timothy Pearson <kb9vqf@pearsoncomputing.net> - */ - -[STR_NAME_MODULE_OPTIONAL_TDE] -en-US = "TDE Integration" - -[STR_DESC_MODULE_OPTIONAL_TDE] -en-US = "System integration of %PRODUCTNAME %PRODUCTVERSION into TDE." - diff --git a/shell/Library_tdebe.mk b/shell/Library_tdebe.mk deleted file mode 100644 index dc5b7355d08e..000000000000 --- a/shell/Library_tdebe.mk +++ /dev/null @@ -1,32 +0,0 @@ -# -*- 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_Library_Library,tdebe1)) - -$(eval $(call gb_Library_use_sdk_api,tdebe1)) - -$(eval $(call gb_Library_use_externals,tdebe1,\ - boost_headers \ - tde \ -)) - -$(eval $(call gb_Library_use_libraries,tdebe1,\ - cppu \ - cppuhelper \ - sal \ -)) - -$(eval $(call gb_Library_set_componentfile,tdebe1,shell/source/backends/kdebe/tdebe1)) - -$(eval $(call gb_Library_add_exception_objects,tdebe1,\ - shell/source/backends/kdebe/kdeaccess \ - shell/source/backends/kdebe/kdebackend \ -)) - -# vim: set shiftwidth=4 tabstop=4 noexpandtab: diff --git a/shell/Module_shell.mk b/shell/Module_shell.mk index cfe7aa061cef..d1a54b9cf9ea 100644 --- a/shell/Module_shell.mk +++ b/shell/Module_shell.mk @@ -36,12 +36,6 @@ $(eval $(call gb_Module_add_targets,shell,\ )) endif -ifeq ($(ENABLE_TDE),TRUE) -$(eval $(call gb_Module_add_targets,shell,\ - Library_tdebe \ -)) -endif - ifeq ($(OS),WNT) $(eval $(call gb_Module_add_targets,shell,\ diff --git a/shell/source/backends/kdebe/kdeaccess.cxx b/shell/source/backends/kdebe/kdeaccess.cxx deleted file mode 100644 index a0a515612b92..000000000000 --- a/shell/source/backends/kdebe/kdeaccess.cxx +++ /dev/null @@ -1,297 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "sal/config.h" - -#include "com/sun/star/uno/Any.hxx" -#include "cppu/unotype.hxx" -#include "osl/diagnose.h" -#include "osl/file.h" -#include "rtl/string.h" -#include "rtl/ustring.hxx" - -#include "shell/kde_headers.h" - -#include "kdeaccess.hxx" - -#define SPACE ' ' -#define COMMA ',' -#define SEMI_COLON ';' - -namespace kdeaccess { - -namespace { - -namespace uno = css::uno ; - -} - -css::beans::Optional< css::uno::Any > getValue(OUString const & id) { - if ( id == "ExternalMailer" ) { - KEMailSettings aEmailSettings; - QString aClientProgram; - OUString sClientProgram; - - aClientProgram = aEmailSettings.getSetting( KEMailSettings::ClientProgram ); - if ( aClientProgram.isEmpty() ) - aClientProgram = "kmail"; - else - aClientProgram = aClientProgram.section(SPACE, 0, 0); - sClientProgram = reinterpret_cast<const sal_Unicode *>(aClientProgram.ucs2()); - return css::beans::Optional< css::uno::Any >( - true, uno::makeAny( sClientProgram ) ); - } else if (id == "SourceViewFontHeight") - { - QFont aFixedFont; - short nFontHeight; - - aFixedFont = KGlobalSettings::fixedFont(); - nFontHeight = aFixedFont.pointSize(); - return css::beans::Optional< css::uno::Any >( - true, uno::makeAny( nFontHeight ) ); - } else if (id == "SourceViewFontName") - { - QFont aFixedFont; - QString aFontName; - OUString sFontName; - - aFixedFont = KGlobalSettings::fixedFont(); - aFontName = aFixedFont.family(); - sFontName = reinterpret_cast<const sal_Unicode *>(aFontName.ucs2()); - return css::beans::Optional< css::uno::Any >( - true, uno::makeAny( sFontName ) ); - } else if (id == "EnableATToolSupport") - { - /* does not make much sense without an accessibility bridge */ - bool ATToolSupport = false; - return css::beans::Optional< css::uno::Any >( - true, uno::makeAny( OUString::boolean( ATToolSupport ) ) ); - } else if (id == "WorkPathVariable") - { - QString aDocumentsDir( KGlobalSettings::documentPath() ); - OUString sDocumentsDir; - OUString sDocumentsURL; - if ( aDocumentsDir.endsWith(QChar('/')) ) - aDocumentsDir.truncate ( aDocumentsDir.length() - 1 ); - sDocumentsDir = reinterpret_cast<const sal_Unicode *>(aDocumentsDir.ucs2()); - osl_getFileURLFromSystemPath( sDocumentsDir.pData, &sDocumentsURL.pData ); - return css::beans::Optional< css::uno::Any >( - true, uno::makeAny( sDocumentsURL ) ); - } else if (id == "ooInetFTPProxyName") - { - QString aFTPProxy; - switch ( KProtocolManager::proxyType() ) - { - case KProtocolManager::ManualProxy: // Proxies are manually configured - aFTPProxy = KProtocolManager::proxyFor( "FTP" ); - break; - case KProtocolManager::PACProxy: // A proxy configuration URL has been given - case KProtocolManager::WPADProxy: // A proxy should be automatically discovered - case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables -// In such cases, the proxy address is not stored in KDE, but determined dynamically. -// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... -// The best we can do here is to ask the current value for a given address. - aFTPProxy = KProtocolManager::proxyForURL( "ftp://ftp.openoffice.org" ); - break; - default: // No proxy is used - break; - } - if ( !aFTPProxy.isEmpty() ) - { - KURL aProxy(aFTPProxy); - OUString sProxy = reinterpret_cast<const sal_Unicode *>(aProxy.host().ucs2()); - return css::beans::Optional< css::uno::Any >( - true, uno::makeAny( sProxy ) ); - } - } else if (id == "ooInetFTPProxyPort") - { - QString aFTPProxy; - switch ( KProtocolManager::proxyType() ) - { - case KProtocolManager::ManualProxy: // Proxies are manually configured - aFTPProxy = KProtocolManager::proxyFor( "FTP" ); - break; - case KProtocolManager::PACProxy: // A proxy configuration URL has been given - case KProtocolManager::WPADProxy: // A proxy should be automatically discovered - case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables -// In such cases, the proxy address is not stored in KDE, but determined dynamically. -// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... -// The best we can do here is to ask the current value for a given address. - aFTPProxy = KProtocolManager::proxyForURL( "ftp://ftp.openoffice.org" ); - break; - default: // No proxy is used - break; - } - if ( !aFTPProxy.isEmpty() ) - { - KURL aProxy(aFTPProxy); - sal_Int32 nPort = aProxy.port(); - return css::beans::Optional< css::uno::Any >( - true, uno::makeAny( nPort ) ); - } - } else if (id == "ooInetHTTPProxyName") - { - QString aHTTPProxy; - switch ( KProtocolManager::proxyType() ) - { - case KProtocolManager::ManualProxy: // Proxies are manually configured - aHTTPProxy = KProtocolManager::proxyFor( "HTTP" ); - break; - case KProtocolManager::PACProxy: // A proxy configuration URL has been given - case KProtocolManager::WPADProxy: // A proxy should be automatically discovered - case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables -// In such cases, the proxy address is not stored in KDE, but determined dynamically. -// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... -// The best we can do here is to ask the current value for a given address. - aHTTPProxy = KProtocolManager::proxyForURL( "http://http.openoffice.org" ); - break; - default: // No proxy is used - break; - } - if ( !aHTTPProxy.isEmpty() ) - { - KURL aProxy(aHTTPProxy); - OUString sProxy = reinterpret_cast<const sal_Unicode *>(aProxy.host().ucs2()); - return css::beans::Optional< css::uno::Any >( - true, uno::makeAny( sProxy ) ); - } - } else if (id == "ooInetHTTPProxyPort") - { - QString aHTTPProxy; - switch ( KProtocolManager::proxyType() ) - { - case KProtocolManager::ManualProxy: // Proxies are manually configured - aHTTPProxy = KProtocolManager::proxyFor( "HTTP" ); - break; - case KProtocolManager::PACProxy: // A proxy configuration URL has been given - case KProtocolManager::WPADProxy: // A proxy should be automatically discovered - case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables -// In such cases, the proxy address is not stored in KDE, but determined dynamically. -// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... -// The best we can do here is to ask the current value for a given address. - aHTTPProxy = KProtocolManager::proxyForURL( "http://http.openoffice.org" ); - break; - default: // No proxy is used - break; - } - if ( !aHTTPProxy.isEmpty() ) - { - KURL aProxy(aHTTPProxy); - sal_Int32 nPort = aProxy.port(); - return css::beans::Optional< css::uno::Any >( - true, uno::makeAny( nPort ) ); - } - } else if (id == "ooInetHTTPSProxyName") - { - QString aHTTPSProxy; - switch ( KProtocolManager::proxyType() ) - { - case KProtocolManager::ManualProxy: // Proxies are manually configured - aHTTPSProxy = KProtocolManager::proxyFor( "HTTPS" ); - break; - case KProtocolManager::PACProxy: // A proxy configuration URL has been given - case KProtocolManager::WPADProxy: // A proxy should be automatically discovered - case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables -// In such cases, the proxy address is not stored in KDE, but determined dynamically. -// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... -// The best we can do here is to ask the current value for a given address. - aHTTPSProxy = KProtocolManager::proxyForURL( "https://https.openoffice.org" ); - break; - default: // No proxy is used - break; - } - if ( !aHTTPSProxy.isEmpty() ) - { - KURL aProxy(aHTTPSProxy); - OUString sProxy = reinterpret_cast<const sal_Unicode *>(aProxy.host().ucs2()); - return css::beans::Optional< css::uno::Any >( - true, uno::makeAny( sProxy ) ); - } - } else if (id == "ooInetHTTPSProxyPort") - { - QString aHTTPSProxy; - switch ( KProtocolManager::proxyType() ) - { - case KProtocolManager::ManualProxy: // Proxies are manually configured - aHTTPSProxy = KProtocolManager::proxyFor( "HTTPS" ); - break; - case KProtocolManager::PACProxy: // A proxy configuration URL has been given - case KProtocolManager::WPADProxy: // A proxy should be automatically discovered - case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables -// In such cases, the proxy address is not stored in KDE, but determined dynamically. -// The proxy address may depend on the requested address, on the time of the day, on the speed of the wind... -// The best we can do here is to ask the current value for a given address. - aHTTPSProxy = KProtocolManager::proxyForURL( "https://https.openoffice.org" ); - break; - default: // No proxy is used - break; - } - if ( !aHTTPSProxy.isEmpty() ) - { - KURL aProxy(aHTTPSProxy); - sal_Int32 nPort = aProxy.port(); - return css::beans::Optional< css::uno::Any >( - true, uno::makeAny( nPort ) ); - } - } else if ( id == "ooInetNoProxy" ) { - QString aNoProxyFor; - switch ( KProtocolManager::proxyType() ) - { - case KProtocolManager::ManualProxy: // Proxies are manually configured - case KProtocolManager::PACProxy: // A proxy configuration URL has been given - case KProtocolManager::WPADProxy: // A proxy should be automatically discovered - case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables - aNoProxyFor = KProtocolManager::noProxyFor(); - break; - default: // No proxy is used - break; - } - if ( !aNoProxyFor.isEmpty() ) - { - OUString sNoProxyFor; - - aNoProxyFor = aNoProxyFor.replace( COMMA, SEMI_COLON ); - sNoProxyFor = reinterpret_cast<const sal_Unicode *>(aNoProxyFor.ucs2()); - return css::beans::Optional< css::uno::Any >( - true, uno::makeAny( sNoProxyFor ) ); - } - } else if ( id == "ooInetProxyType" ) { - int nProxyType; - switch ( KProtocolManager::proxyType() ) - { - case KProtocolManager::ManualProxy: // Proxies are manually configured - case KProtocolManager::PACProxy: // A proxy configuration URL has been given - case KProtocolManager::WPADProxy: // A proxy should be automatically discovered - case KProtocolManager::EnvVarProxy: // Use the proxy values set through environment variables - nProxyType = 1; - break; - default: // No proxy is used - nProxyType = 0; - } - return css::beans::Optional< css::uno::Any >( - true, uno::makeAny( (sal_Int32) nProxyType ) ); - } else { - OSL_ASSERT(false); // this cannot happen - } - return css::beans::Optional< css::uno::Any >(); -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/source/backends/kdebe/kdeaccess.hxx b/shell/source/backends/kdebe/kdeaccess.hxx deleted file mode 100644 index 223da8c2aa95..000000000000 --- a/shell/source/backends/kdebe/kdeaccess.hxx +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_SHELL_SOURCE_BACKENDS_KDEBE_KDEACCESS_HXX -#define INCLUDED_SHELL_SOURCE_BACKENDS_KDEBE_KDEACCESS_HXX - -#include "sal/config.h" - -#include "com/sun/star/beans/Optional.hpp" - -namespace com { namespace sun { namespace star { namespace uno { - class Any; -} } } } -namespace rtl { class OUString; } - -namespace kdeaccess { - -css::beans::Optional< css::uno::Any > getValue(OUString const & id); - -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/source/backends/kdebe/kdebackend.cxx b/shell/source/backends/kdebe/kdebackend.cxx deleted file mode 100644 index 3d200a8e7e7f..000000000000 --- a/shell/source/backends/kdebe/kdebackend.cxx +++ /dev/null @@ -1,181 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "sal/config.h" - -#include "com/sun/star/beans/Optional.hpp" -#include "com/sun/star/beans/PropertyVetoException.hpp" -#include "com/sun/star/beans/UnknownPropertyException.hpp" -#include "com/sun/star/beans/XPropertyChangeListener.hpp" -#include "com/sun/star/beans/XPropertySet.hpp" -#include "com/sun/star/beans/XPropertySetInfo.hpp" -#include "com/sun/star/beans/XVetoableChangeListener.hpp" -#include "com/sun/star/lang/IllegalArgumentException.hpp" -#include "com/sun/star/lang/WrappedTargetException.hpp" -#include "com/sun/star/lang/XMultiComponentFactory.hpp" -#include "com/sun/star/lang/XServiceInfo.hpp" -#include "com/sun/star/uno/Any.hxx" -#include "com/sun/star/uno/Reference.hxx" -#include "com/sun/star/uno/RuntimeException.hpp" -#include "com/sun/star/uno/Sequence.hxx" -#include "com/sun/star/uno/XComponentContext.hpp" -#include "com/sun/star/uno/XCurrentContext.hpp" -#include "cppuhelper/factory.hxx" -#include <cppuhelper/implbase.hxx> -#include "cppuhelper/implementationentry.hxx" -#include "cppuhelper/weak.hxx" -#include "rtl/string.h" -#include "rtl/ustring.h" -#include "rtl/ustring.hxx" -#include "sal/types.h" -#include "uno/current_context.hxx" - -#include "shell/kde_headers.h" - -#include "kdeaccess.hxx" - -namespace { - -OUString SAL_CALL getServiceImplementationName() { - return OUString( - "com.sun.star.comp.configuration.backend.KDEBackend"); -} - -css::uno::Sequence< OUString > SAL_CALL getServiceSupportedServiceNames() { - OUString name( - "com.sun.star.configuration.backend.KDEBackend"); - return css::uno::Sequence< OUString >(&name, 1); -} - -class Service: - public cppu::WeakImplHelper< - css::lang::XServiceInfo, css::beans::XPropertySet > -{ -public: - Service(); - Service(const Service&) = delete; - Service& operator=(const Service&) = delete; - -private: - virtual ~Service() override {} - - virtual OUString SAL_CALL getImplementationName() override - { return getServiceImplementationName(); } - - virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override - { return ServiceName == getSupportedServiceNames()[0]; } - - virtual css::uno::Sequence< OUString > SAL_CALL - getSupportedServiceNames() override - { return getServiceSupportedServiceNames(); } - - virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL - getPropertySetInfo() override - { return css::uno::Reference< css::beans::XPropertySetInfo >(); } - - virtual void SAL_CALL setPropertyValue( - OUString const &, css::uno::Any const &) override; - - virtual css::uno::Any SAL_CALL getPropertyValue( - OUString const & PropertyName) override; - - virtual void SAL_CALL addPropertyChangeListener( - OUString const &, - css::uno::Reference< css::beans::XPropertyChangeListener > const &) override - {} - - virtual void SAL_CALL removePropertyChangeListener( - OUString const &, - css::uno::Reference< css::beans::XPropertyChangeListener > const &) override - {} - - virtual void SAL_CALL addVetoableChangeListener( - OUString const &, - css::uno::Reference< css::beans::XVetoableChangeListener > const &) override - {} - - virtual void SAL_CALL removeVetoableChangeListener( - OUString const &, - css::uno::Reference< css::beans::XVetoableChangeListener > const &) override - {} - - bool enabled_; -}; - -Service::Service(): enabled_(false) { - css::uno::Reference< css::uno::XCurrentContext > context( - css::uno::getCurrentContext()); - if (context.is()) { - OUString desktop; - context->getValueByName( - "system.desktop-environment") >>= desktop; - enabled_ = desktop == "KDE" && KApplication::kApplication() != nullptr; - } -} - -void Service::setPropertyValue(OUString const &, css::uno::Any const &) -{ - throw css::lang::IllegalArgumentException( - "setPropertyValue not supported", - static_cast< cppu::OWeakObject * >(this), -1); -} - -css::uno::Any Service::getPropertyValue(OUString const & PropertyName) -{ - if ( PropertyName == "EnableATToolSupport" || PropertyName == "ExternalMailer" || PropertyName == "SourceViewFontHeight" - || PropertyName == "SourceViewFontName" || PropertyName == "WorkPathVariable" || PropertyName == "ooInetFTPProxyName" - || PropertyName == "ooInetFTPProxyPort" || PropertyName == "ooInetHTTPProxyName" || PropertyName == "ooInetHTTPProxyPort" - || PropertyName == "ooInetHTTPSProxyName" || PropertyName == "ooInetHTTPSProxyPort" || PropertyName == "ooInetNoProxy" - || PropertyName == "ooInetProxyType" || PropertyName == "TemplatePathVariable" ) - { - return css::uno::makeAny( - enabled_ - ? kdeaccess::getValue(PropertyName) - : css::beans::Optional< css::uno::Any >()); - } else if (PropertyName == "givenname" || PropertyName == "sn") { - return css::uno::makeAny(css::beans::Optional< css::uno::Any >()); - //TODO: obtain values from KDE? - } - throw css::beans::UnknownPropertyException( - PropertyName, static_cast< cppu::OWeakObject * >(this)); -} - -css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( - css::uno::Reference< css::uno::XComponentContext > const &) -{ - return static_cast< cppu::OWeakObject * >(new Service); -} - -static cppu::ImplementationEntry const services[] = { - { &createInstance, &getServiceImplementationName, - &getServiceSupportedServiceNames, &cppu::createSingleComponentFactory, nullptr, - 0 }, - { nullptr, nullptr, nullptr, nullptr, nullptr, 0 } -}; - -} - -extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL kdebe1_component_getFactory( - char const * pImplName, void * pServiceManager, void * pRegistryKey) -{ - return cppu::component_getFactoryHelper( - pImplName, pServiceManager, pRegistryKey, services); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/source/backends/kdebe/tdebe1.component b/shell/source/backends/kdebe/tdebe1.component deleted file mode 100644 index 2a7c54cf4240..000000000000 --- a/shell/source/backends/kdebe/tdebe1.component +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - --> - -<component loader="com.sun.star.loader.SharedLibrary" - xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.configuration.backend.TDEBackend"> - <service name="com.sun.star.configuration.backend.TDEBackend"/> - </implementation> -</component> diff --git a/solenv/gbuild/CppunitTest.mk b/solenv/gbuild/CppunitTest.mk index 4bccabf6e46e..0b9478a509b6 100644 --- a/solenv/gbuild/CppunitTest.mk +++ b/solenv/gbuild/CppunitTest.mk @@ -225,7 +225,7 @@ $(call gb_CppunitTest_get_target,$(1)) : $(if $(filter $(2),$(true)),, \ $(if $(ENABLE_GTK),$(call gb_Library_get_target,vclplug_gtk)) \ $(if $(ENABLE_GTK3),$(call gb_Library_get_target,vclplug_gtk3)) \ $(if $(ENABLE_KDE4),$(call gb_Library_get_target,vclplug_kde4)) \ - $(if $(ENABLE_TDE),$(call gb_Library_get_target,vclplug_tde))) + ) endif endef diff --git a/sysui/CustomTarget_share.mk b/sysui/CustomTarget_share.mk index c81edd50f1af..aeb94c0bc0ea 100644 --- a/sysui/CustomTarget_share.mk +++ b/sysui/CustomTarget_share.mk @@ -12,8 +12,6 @@ include $(SRCDIR)/sysui/productlist.mk ifeq ($(ENABLE_GIO),TRUE) brand_URIPARAM := --urls -else ifeq ($(ENABLE_TDE),TRUE) - brand_URIPARAM := --urls else ifeq ($(ENABLE_KDE4),TRUE) brand_URIPARAM := --urls else diff --git a/vcl/CustomTarget_tde_moc.mk b/vcl/CustomTarget_tde_moc.mk deleted file mode 100644 index 72c8699f741d..000000000000 --- a/vcl/CustomTarget_tde_moc.mk +++ /dev/null @@ -1,21 +0,0 @@ -# -*- 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_CustomTarget_CustomTarget,vcl/unx/kde/fpicker)) - -$(call gb_CustomTarget_get_target,vcl/unx/kde/fpicker) : \ - $(call gb_CustomTarget_get_workdir,vcl/unx/kde/fpicker)/kdefilepicker.moc.cxx - -$(call gb_CustomTarget_get_workdir,vcl/unx/kde/fpicker)/kdefilepicker.moc.cxx :\ - $(SRCDIR)/vcl/unx/kde/fpicker/kdefilepicker.hxx \ - | $(call gb_CustomTarget_get_workdir,vcl/unx/kde/fpicker)/.dir - $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),MOC,1) - cat $< | grep -v 'FILTER_OUT_KDE' | $(TDE_MOC) -o $@ -f$< - -# vim:set shiftwidth=4 tabstop=4 noexpandtab: diff --git a/vcl/Executable_tdefilepicker.mk b/vcl/Executable_tdefilepicker.mk deleted file mode 100644 index c779059bed2b..000000000000 --- a/vcl/Executable_tdefilepicker.mk +++ /dev/null @@ -1,51 +0,0 @@ -# -*- 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,tdefilepicker)) - -$(eval $(call gb_Executable_add_defs,tdefilepicker,\ - $(TDE_CFLAGS) \ - -DENABLE_TDE \ -)) - -$(eval $(call gb_Executable_set_include,tdefilepicker,\ - $$(INCLUDE) \ - -I$(SRCDIR)/vcl/inc \ - -I$(SRCDIR)/vcl/inc/unx/kde \ -)) - -$(eval $(call gb_Executable_use_libraries,tdefilepicker,\ - sal \ -)) - -$(eval $(call gb_Executable_add_libs,tdefilepicker,\ - $(TDE_LIBS) \ - -ltdeio -lX11 \ -)) - -$(eval $(call gb_Executable_add_exception_objects,tdefilepicker,\ - vcl/unx/kde/fpicker/kdecommandthread \ - vcl/unx/kde/fpicker/kdefilepicker \ - vcl/unx/kde/fpicker/kdefpmain \ - vcl/unx/kde/fpicker/kdemodalityfilter \ -)) - -$(eval $(call gb_Executable_add_generated_exception_objects,tdefilepicker,\ - CustomTarget/vcl/unx/kde/fpicker/kdefilepicker.moc \ -)) - -$(eval $(call gb_Executable_set_warnings_not_errors,tdefilepicker)) - -# TDE/TQt consider -Wshadow more trouble than benefit -$(eval $(call gb_Executable_add_cxxflags,kdefilepicker,\ - -Wno-shadow \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/vcl/Library_vclplug_tde.mk b/vcl/Library_vclplug_tde.mk deleted file mode 100644 index 2dd582a3a40a..000000000000 --- a/vcl/Library_vclplug_tde.mk +++ /dev/null @@ -1,86 +0,0 @@ -# -*- 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/. -# -# Copyright (C) 2012, Timothy Pearson <kb9vqf@pearsoncomputing.net> -# - -$(eval $(call gb_Library_Library,vclplug_tde)) - -$(eval $(call gb_Library_set_include,vclplug_tde,\ - $$(INCLUDE) \ - -I$(SRCDIR)/vcl/inc \ - -I$(SRCDIR)/vcl/inc/unx/kde \ -)) - -$(eval $(call gb_Library_set_include,vclplug_tde,\ - $$(INCLUDE) \ - $$(TDE_CFLAGS) \ -)) - -$(eval $(call gb_Library_add_defs,vclplug_tde,\ - -DVCLPLUG_TDE_IMPLEMENTATION \ -)) - -$(eval $(call gb_Library_use_sdk_api,vclplug_tde)) - -$(eval $(call gb_Library_add_libs,vclplug_tde,\ - $(TDE_LIBS) \ - -lX11 \ - -lXext \ - -lSM \ - -lICE \ -)) - -$(eval $(call gb_Library_use_libraries,vclplug_tde,\ - vclplug_gen \ - vcl \ - tl \ - utl \ - sot \ - ucbhelper \ - basegfx \ - comphelper \ - cppuhelper \ - i18nlangtag \ - i18nutil \ - $(if $(ENABLE_JAVA), \ - jvmaccess) \ - cppu \ - sal \ -)) - -$(eval $(call gb_Library_use_externals,vclplug_tde,\ - boost_headers \ - epoxy \ - icuuc \ -)) - -$(eval $(call gb_Library_add_exception_objects,vclplug_tde,\ - vcl/unx/kde/kdedata \ - vcl/unx/kde/salnativewidgets-kde \ - vcl/unx/kde/UnxCommandThread \ - vcl/unx/kde/UnxFilePicker \ - vcl/unx/kde/UnxNotifyThread \ -)) - -# TDE/TQt consider -Wshadow more trouble than benefit -$(eval $(call gb_Library_add_cxxflags,vclplug_tde,\ - -Wno-shadow \ -)) - -$(eval $(call gb_Library_set_warnings_not_errors,vclplug_tde)) - -ifeq ($(OS),LINUX) -$(eval $(call gb_Library_add_libs,vclplug_tde,\ - -lm \ - -ldl \ - -lpthread \ -)) -endif - -# vim: set noet sw=4 ts=4: diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk index c7d225b83a48..54ba2bf027c6 100644 --- a/vcl/Module_vcl.mk +++ b/vcl/Module_vcl.mk @@ -75,13 +75,6 @@ $(eval $(call gb_Module_add_targets,vcl,\ Library_vclplug_gtk3 \ )) endif -ifneq ($(ENABLE_TDE),) -$(eval $(call gb_Module_add_targets,vcl,\ - CustomTarget_tde_moc \ - Executable_tdefilepicker \ - Library_vclplug_tde \ -)) -endif ifneq ($(ENABLE_KDE4),) $(eval $(call gb_Module_add_targets,vcl,\ CustomTarget_kde4_moc \ diff --git a/vcl/inc/unx/kde/kdedata.hxx b/vcl/inc/unx/kde/kdedata.hxx deleted file mode 100644 index 926909aac910..000000000000 --- a/vcl/inc/unx/kde/kdedata.hxx +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_VCL_INC_UNX_KDE_KDEDATA_HXX -#define INCLUDED_VCL_INC_UNX_KDE_KDEDATA_HXX - -#include <unx/saldisp.hxx> -#include <unx/saldata.hxx> -#include <unx/salframe.h> -#include <unx/salgdi.h> - -#include <memory> - -class KDEData : public X11SalData -{ -public: - KDEData( SalInstance *pInstance ) : X11SalData( SAL_DATA_KDE3, pInstance ) {} - virtual ~KDEData() override; - - virtual void Init() override; - virtual void initNWF() override; - virtual void deInitNWF() override; -}; - -class SalKDEDisplay : public SalX11Display -{ -public: - SalKDEDisplay( Display* pDisp ); - virtual ~SalKDEDisplay() override; -}; - -class KDESalFrame : public X11SalFrame -{ - static const int nMaxGraphics = 2; - - struct GraphicsHolder - { - std::unique_ptr<X11SalGraphics> pGraphics; - bool bInUse; - GraphicsHolder() : bInUse( false ) {} - }; - GraphicsHolder m_aGraphics[ nMaxGraphics ]; - -public: - KDESalFrame( SalFrame* pParent, SalFrameStyleFlags ); - virtual ~KDESalFrame() override; - - virtual SalGraphics* AcquireGraphics() override; - virtual void ReleaseGraphics( SalGraphics *pGraphics ) override; - virtual void updateGraphics( bool bClear ) override; - virtual void UpdateSettings( AllSettings& rSettings ) override; - virtual void Show( bool bVisible, bool bNoActivate = false ) override; -}; - -class KDESalInstance : public X11SalInstance -{ -protected: - virtual SalX11Display* CreateDisplay() const override; - -public: - KDESalInstance( SalYieldMutex* pMutex ) - : X11SalInstance( pMutex ) {} - virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override; - - virtual bool hasNativeFileSelection() const override { return true; } - - virtual css::uno::Reference< css::ui::dialogs::XFilePicker2 > - createFilePicker( const css::uno::Reference< css::uno::XComponentContext >& ) override; -}; - -class KDEXLib : public SalXLib -{ - bool m_bStartupDone; - void* m_pApplication; - char** m_pFreeCmdLineArgs; - char** m_pAppCmdLineArgs; - int m_nFakeCmdLineArgs; -public: - KDEXLib() : SalXLib(), - m_bStartupDone( false ), - m_pApplication( nullptr ), - m_pFreeCmdLineArgs( nullptr ), - m_pAppCmdLineArgs( nullptr ), - m_nFakeCmdLineArgs( 0 ) - {} - virtual ~KDEXLib() override; - virtual void Init() override; - - void doStartup(); -}; - -#endif // INCLUDED_VCL_INC_UNX_KDE_KDEDATA_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/kde/FPServiceInfo.hxx b/vcl/unx/kde/FPServiceInfo.hxx deleted file mode 100644 index 34096b9f6cf9..000000000000 --- a/vcl/unx/kde/FPServiceInfo.hxx +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_VCL_UNX_KDE_FPSERVICEINFO_HXX -#define INCLUDED_VCL_UNX_KDE_FPSERVICEINFO_HXX - -#include <config_vclplug.h> - -#if ENABLE_TDE - -// the service names -#define FILE_PICKER_SERVICE_NAME "com.sun.star.ui.dialogs.TDEFilePicker" - -#else // ENABLE_TDE - -// the service names -#define FILE_PICKER_SERVICE_NAME "com.sun.star.ui.dialogs.KDEFilePicker" - -#endif // ENABLE_TDE - -// the implementation names -#define FILE_PICKER_IMPL_NAME "com.sun.star.ui.dialogs.UnxFilePicker" - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/kde/UnxCommandThread.cxx b/vcl/unx/kde/UnxCommandThread.cxx deleted file mode 100644 index e2ca566dcce2..000000000000 --- a/vcl/unx/kde/UnxCommandThread.cxx +++ /dev/null @@ -1,300 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <UnxCommandThread.hxx> -#include <UnxNotifyThread.hxx> - -#include <rtl/ustring.hxx> -#include <rtl/ustrbuf.hxx> - -#include <unistd.h> -#include <string.h> -#include <iostream> -#include <comphelper/sequence.hxx> - -using namespace ::com::sun::star; - -namespace { - -::std::list< OUString > tokenize( const OUString &rCommand ) -{ - ::std::list< OUString > aList; - OUStringBuffer aBuffer( 1024 ); - - const sal_Unicode *pUnicode = rCommand.getStr(); - const sal_Unicode *pEnd = pUnicode + rCommand.getLength(); - bool bQuoted = false; - - for ( ; pUnicode != pEnd; ++pUnicode ) - { - if ( *pUnicode == '\\' ) - { - ++pUnicode; - if ( pUnicode != pEnd ) - { - if ( *pUnicode == 'n' ) - aBuffer.append( "\n" ); - else - aBuffer.append( *pUnicode ); - } - } - else if ( *pUnicode == '"' ) - bQuoted = !bQuoted; - else if ( *pUnicode == ' ' && !bQuoted ) - aList.push_back( aBuffer.makeStringAndClear() ); - else - aBuffer.append( *pUnicode ); - } - aList.push_back( aBuffer.makeStringAndClear() ); - - return aList; -} - -} - -// UnxFilePickerCommandThread - -UnxFilePickerCommandThread::UnxFilePickerCommandThread( UnxFilePickerNotifyThread *pNotifyThread, int nReadFD ) - : m_pNotifyThread( pNotifyThread ), - m_nReadFD( nReadFD ) -{ -} - -UnxFilePickerCommandThread::~UnxFilePickerCommandThread() -{ -} - -bool SAL_CALL UnxFilePickerCommandThread::result() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - return m_aResult; -} - -OUString SAL_CALL UnxFilePickerCommandThread::getCurrentFilter() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - return m_aGetCurrentFilter; -} - -OUString SAL_CALL UnxFilePickerCommandThread::getDirectory() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - return m_aGetDirectory; -} - -uno::Sequence< OUString > SAL_CALL UnxFilePickerCommandThread::getSelectedFiles() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - sal_Int32 nSize = m_aGetFiles.size(); - uno::Sequence< OUString > aFiles( nSize ); - - size_t nIdx = 0; - for ( ::std::list< OUString >::const_iterator it = m_aGetFiles.begin(); - it != m_aGetFiles.end(); ++it, ++nIdx ) - { - aFiles[nIdx] = *it; - } - - return aFiles; -} -uno::Sequence< OUString > SAL_CALL UnxFilePickerCommandThread::getFiles() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - uno::Sequence< OUString > aFiles = getSelectedFiles(); - if (aFiles.getLength() > 1) - aFiles.realloc(1); // we just want the first entry here - - return aFiles; -} - -uno::Any SAL_CALL UnxFilePickerCommandThread::getValue() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - return m_aGetValue; -} - -void SAL_CALL UnxFilePickerCommandThread::run() -{ - osl_setThreadName("UnxFilePickerCommandThread"); - - if ( m_nReadFD < 0 ) - return; - - sal_Int32 nBufferSize = 1024; // 1 is for testing, 1024 for real use - sal_Char *pBuffer = new sal_Char[nBufferSize]; - sal_Char *pBufferEnd = pBuffer + nBufferSize; - - sal_Char *pWhereToRead = pBuffer; - sal_Char *pEntryBegin = pBuffer; - sal_Int32 nBytesRead = 0; - bool bShouldExit = false; - while ( !bShouldExit && ( nBytesRead = read( m_nReadFD, pWhereToRead, pBufferEnd - pWhereToRead ) ) > 0 ) - { - bool bFoundNL = false; - sal_Char *pWhereToReadEnd = pWhereToRead + nBytesRead; - sal_Char *pEntryEnd = pWhereToRead; - do { - for ( ; pEntryEnd < pWhereToReadEnd && *pEntryEnd != '\n'; ++pEntryEnd ) - ; - - if ( pEntryEnd < pWhereToReadEnd ) - { - bFoundNL = true; - *pEntryEnd = 0; - - if ( strcmp( pEntryBegin, "exited" ) == 0 ) - bShouldExit = true; - else - handleCommand( OUString( pEntryBegin, pEntryEnd - pEntryBegin, RTL_TEXTENCODING_UTF8 )/*, bQuit*/ ); - - pEntryBegin = pEntryEnd + 1; - } - } while ( pEntryEnd < pWhereToReadEnd ); - - if ( bFoundNL ) - { - if ( pEntryBegin < pBufferEnd ) - memmove( pBuffer, pEntryBegin, pWhereToReadEnd - pEntryBegin ); - } - else - { - // enlarge the buffer size - nBufferSize *= 2; - sal_Char *pNewBuffer = new sal_Char[nBufferSize]; - if ( pEntryBegin < pBufferEnd ) - memcpy( pNewBuffer, pEntryBegin, pWhereToReadEnd - pEntryBegin ); - - delete[] pBuffer; - pBuffer = pNewBuffer; - pBufferEnd = pBuffer + nBufferSize; - } - - pWhereToRead = pBuffer + ( pWhereToReadEnd - pEntryBegin ); - pEntryBegin = pBuffer; - } -} - -void SAL_CALL UnxFilePickerCommandThread::handleCommand( const OUString &rCommand ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - -#if OSL_DEBUG_LEVEL > 0 - ::std::cerr << "UnxFilePicker received: \"" << - OUStringToOString( rCommand, RTL_TEXTENCODING_ASCII_US ).getStr() << "\"" << ::std::endl; -#endif - - ::std::list< OUString > aList = tokenize( rCommand ); - - if ( aList.empty() ) - return; - - OUString aCommandName = aList.front(); - aList.pop_front(); - - if ( aCommandName == "accept" ) - { - m_aResult = true; - m_aExecCondition.set(); - } - else if ( aCommandName == "reject" ) - { - m_aResult = false; - m_aExecCondition.set(); - } - else if ( aCommandName == "fileSelectionChanged" ) - { - if ( m_pNotifyThread ) - m_pNotifyThread->fileSelectionChanged(); - } - else if ( aCommandName == "files" ) - { - m_aGetFiles = aList; - m_aGetFilesCondition.set(); - } - else if ( aCommandName == "value" ) - { - OUString aType; - if ( !aList.empty() ) - { - aType = aList.front(); - aList.pop_front(); - } - - if ( aType == "bool" ) - { - bool bValue = !aList.empty() && aList.front().equalsIgnoreAsciiCase("true"); - - m_aGetValue <<= bValue; - m_aGetValueCondition.set(); - } - else if ( aType == "int" ) - { - sal_Int32 nValue = 0; - if ( !aList.empty() ) - nValue = aList.front().toInt32(); - - m_aGetValue <<= nValue; - m_aGetValueCondition.set(); - } - else if ( aType == "string" ) - { - OUString aValue; - if ( !aList.empty() ) - aValue = aList.front(); - - m_aGetValue <<= aValue; - m_aGetValueCondition.set(); - } - else if ( aType == "stringList" ) - { - m_aGetValue <<= comphelper::containerToSequence(aList); - m_aGetValueCondition.set(); - } - else - { - m_aGetValue = uno::Any(); - m_aGetValueCondition.set(); - } - } - else if ( aCommandName == "currentFilter" ) - { - m_aGetCurrentFilter = aList.empty()? OUString(): aList.front(); - m_aGetCurrentFilterCondition.set(); - } - else if ( aCommandName == "currentDirectory" ) - { - m_aGetDirectory = aList.empty()? OUString(): aList.front(); - m_aGetDirectoryCondition.set(); - } - else - { -#if OSL_DEBUG_LEVEL > 0 - ::std::cerr << "Unrecognized command: " - << OUStringToOString( aCommandName, RTL_TEXTENCODING_ASCII_US ).getStr() << "\"" << ::std::endl; -#endif - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/kde/UnxCommandThread.hxx b/vcl/unx/kde/UnxCommandThread.hxx deleted file mode 100644 index 6c3a228e9f5c..000000000000 --- a/vcl/unx/kde/UnxCommandThread.hxx +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_VCL_UNX_KDE_UNXCOMMANDTHREAD_HXX -#define INCLUDED_VCL_UNX_KDE_UNXCOMMANDTHREAD_HXX - -#include <com/sun/star/uno/Any.hxx> -#include <com/sun/star/uno/Sequence.hxx> - -#include <osl/conditn.hxx> -#include <osl/mutex.hxx> -#include <osl/thread.hxx> -#include <rtl/ustring.hxx> - -#include <vcl/svapp.hxx> - -#include <list> - -class UnxFilePickerNotifyThread; - -/** Synchronization for the 'thread-less' version of the fpicker. - - Something like osl::Condition, but calls Application::Yield() while in - wait(). -*/ -class YieldingCondition -{ - ::osl::Mutex m_aMutex; - bool m_bValue; - - bool get() - { - ::osl::MutexGuard aGuard( m_aMutex ); - return m_bValue; - } - -public: - YieldingCondition() { reset(); } - - void reset() - { - ::osl::MutexGuard aGuard( m_aMutex ); - m_bValue = false; - } - - void set() - { - ::osl::MutexGuard aGuard( m_aMutex ); - m_bValue = true; - } - - void wait() - { - while ( !get() ) - Application::Yield(); - } -}; - -class UnxFilePickerCommandThread : public ::osl::Thread -{ -protected: - UnxFilePickerNotifyThread *m_pNotifyThread; - int m_nReadFD; - - ::osl::Mutex m_aMutex; - - YieldingCondition m_aExecCondition; - bool m_aResult; - - ::osl::Condition m_aGetCurrentFilterCondition; - OUString m_aGetCurrentFilter; - - ::osl::Condition m_aGetDirectoryCondition; - OUString m_aGetDirectory; - - ::osl::Condition m_aGetFilesCondition; - ::std::list< OUString > m_aGetFiles; - - ::osl::Condition m_aGetValueCondition; - css::uno::Any m_aGetValue; - -public: - UnxFilePickerCommandThread( UnxFilePickerNotifyThread *pNotifyThread, int nReadFD ); - virtual ~UnxFilePickerCommandThread() override; - - YieldingCondition& SAL_CALL execCondition() { return m_aExecCondition; } - bool SAL_CALL result(); - - ::osl::Condition& SAL_CALL getCurrentFilterCondition() { return m_aGetCurrentFilterCondition; } - OUString SAL_CALL getCurrentFilter(); - - ::osl::Condition& SAL_CALL getDirectoryCondition() { return m_aGetDirectoryCondition; } - OUString SAL_CALL getDirectory(); - - ::osl::Condition& SAL_CALL getFilesCondition() { return m_aGetFilesCondition; } - css::uno::Sequence< OUString > SAL_CALL getSelectedFiles(); - css::uno::Sequence< OUString > SAL_CALL getFiles(); - - ::osl::Condition& SAL_CALL getValueCondition() { return m_aGetValueCondition; } - css::uno::Any SAL_CALL getValue(); - -protected: - virtual void SAL_CALL run() override; - - virtual void SAL_CALL handleCommand( const OUString &rCommand/*, bool &rQuit*/ ); -}; - -#endif // INCLUDED_VCL_UNX_KDE_UNXCOMMANDTHREAD_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/kde/UnxFilePicker.cxx b/vcl/unx/kde/UnxFilePicker.cxx deleted file mode 100644 index 8fbed035a0b3..000000000000 --- a/vcl/unx/kde/UnxFilePicker.cxx +++ /dev/null @@ -1,910 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <com/sun/star/lang/DisposedException.hpp> -#include <com/sun/star/lang/IllegalArgumentException.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/ui/dialogs/TemplateDescription.hpp> -#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp> -#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> -#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> -#include <com/sun/star/ui/dialogs/ControlActions.hpp> - -#include <FPServiceInfo.hxx> - -#include <cppuhelper/interfacecontainer.h> -#include <cppuhelper/supportsservice.hxx> -#include <osl/diagnose.h> -#include <osl/file.hxx> -#include <rtl/ustring.hxx> -#include <rtl/ustrbuf.hxx> -#include <rtl/bootstrap.hxx> -#include <tools/resmgr.hxx> - -#include <UnxFilePicker.hxx> -#include <UnxCommandThread.hxx> -#include <UnxNotifyThread.hxx> - -#include <vcl/fpicker.hrc> -#include <vcl/svapp.hxx> -#include <vcl/sysdata.hxx> -#include <vcl/syswin.hxx> -#include <vcl/window.hxx> - -#include <sys/wait.h> -#include <unistd.h> -#include <fcntl.h> -#include <stdio.h> - -#include <iostream> - -#include <config_vclplug.h> - -using namespace ::com::sun::star; - -using namespace ::com::sun::star::ui::dialogs; -using namespace ::com::sun::star::ui::dialogs::TemplateDescription; - -// helper functions - -namespace -{ - uno::Sequence<OUString> SAL_CALL FilePicker_getSupportedServiceNames() - { - uno::Sequence<OUString> aRet(3); - aRet[0] = "com.sun.star.ui.dialogs.FilePicker"; - aRet[1] = "com.sun.star.ui.dialogs.SystemFilePicker"; -#if ENABLE_TDE - aRet[2] = "com.sun.star.ui.dialogs.TDEFilePicker"; -#else // ENABLE_TDE - aRet[2] = "com.sun.star.ui.dialogs.KDEFilePicker"; -#endif // ENABLE_TDE - return aRet; - } - -void appendEscaped( OUStringBuffer &rBuffer, const OUString &rString ) -{ - const sal_Unicode *pUnicode = rString.getStr(); - const sal_Unicode *pEnd = pUnicode + rString.getLength(); - - rBuffer.append( "\"" ); - - for ( ; pUnicode != pEnd; ++pUnicode ) - { - if ( *pUnicode == '\\' ) - rBuffer.append( "\\\\" ); - else if ( *pUnicode == '"' ) - rBuffer.append( "\\\"" ); - else if ( *pUnicode == '\n' ) - rBuffer.append( "\\n" ); - else - rBuffer.append( *pUnicode ); - } - - rBuffer.append( "\"" ); -} - -bool controlIdInfo( sal_Int16 nControlId, OUString &rType, sal_Int32 &rTitleId ) -{ - typedef struct { - sal_Int16 nId; - const OUString *pType; - sal_Int32 nTitle; - } ElementToName; - - const OUString aCheckBox( "checkbox" ); - const OUString aControl( "control" ); - const OUString aEdit( "edit" ); - const OUString aLabel( "label" ); - const OUString aListBox( "listbox" ); - const OUString aPushButton( "pushbutton" ); - - const ElementToName *pPtr; - const ElementToName pArray[] = - { - { CommonFilePickerElementIds::PUSHBUTTON_OK, &aPushButton, 0/*FIXME?*/ }, - { CommonFilePickerElementIds::PUSHBUTTON_CANCEL, &aPushButton, 0/*FIXME?*/ }, - { CommonFilePickerElementIds::LISTBOX_FILTER, &aListBox, 0/*FIXME?*/ }, - { CommonFilePickerElementIds::CONTROL_FILEVIEW, &aControl, 0/*FIXME?*/ }, - { CommonFilePickerElementIds::EDIT_FILEURL, &aEdit, 0/*FIXME?*/ }, - { CommonFilePickerElementIds::LISTBOX_FILTER_LABEL, &aLabel, 0/*FIXME?*/ }, - { CommonFilePickerElementIds::EDIT_FILEURL_LABEL, &aLabel, 0/*FIXME?*/ }, - - { ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, &aCheckBox, STR_SVT_FILEPICKER_AUTO_EXTENSION }, - { ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, &aCheckBox, STR_SVT_FILEPICKER_PASSWORD }, - { ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS, &aCheckBox, STR_SVT_FILEPICKER_FILTER_OPTIONS }, - { ExtendedFilePickerElementIds::CHECKBOX_READONLY, &aCheckBox, STR_SVT_FILEPICKER_READONLY }, - { ExtendedFilePickerElementIds::CHECKBOX_LINK, &aCheckBox, STR_SVT_FILEPICKER_INSERT_AS_LINK }, - { ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, &aCheckBox, STR_SVT_FILEPICKER_SHOW_PREVIEW }, - { ExtendedFilePickerElementIds::PUSHBUTTON_PLAY, &aPushButton, STR_SVT_FILEPICKER_PLAY }, - { ExtendedFilePickerElementIds::LISTBOX_VERSION, &aListBox, STR_SVT_FILEPICKER_VERSION }, - { ExtendedFilePickerElementIds::LISTBOX_TEMPLATE, &aListBox, STR_SVT_FILEPICKER_TEMPLATES }, - { ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE, &aListBox, STR_SVT_FILEPICKER_IMAGE_TEMPLATE }, - { ExtendedFilePickerElementIds::CHECKBOX_SELECTION, &aCheckBox, STR_SVT_FILEPICKER_SELECTION }, - { 0, nullptr, 0 } - }; - - for ( pPtr = pArray; pPtr->nId && ( pPtr->nId != nControlId ); ++pPtr ) - ; - - if ( pPtr->nId == nControlId ) - { - rType = *(pPtr->pType); - rTitleId = pPtr->nTitle; - - return true; - } - - return false; -} - -bool controlActionInfo( sal_Int16 nControlAction, OUString &rType ) -{ - typedef struct { - sal_Int16 nId; - const OUString pType; - } ElementToName; - - const ElementToName *pPtr; - const ElementToName pArray[] = - { - { ControlActions::ADD_ITEM, OUString( "addItem" ) }, - { ControlActions::ADD_ITEMS, OUString( "addItems" ) }, - { ControlActions::DELETE_ITEM, OUString( "deleteItem" ) }, - { ControlActions::DELETE_ITEMS, OUString( "deleteItems" ) }, - { ControlActions::SET_SELECT_ITEM, OUString( "setSelectedItem" ) }, - { ControlActions::GET_ITEMS, OUString( "getItems" ) }, - { ControlActions::GET_SELECTED_ITEM, OUString( "getSelectedItem" ) }, - { ControlActions::GET_SELECTED_ITEM_INDEX, OUString( "getSelectedItemIndex" ) }, - { ControlActions::SET_HELP_URL, OUString( "setHelpURL" ) }, - { ControlActions::GET_HELP_URL, OUString( "getHelpURL" ) }, - { 0, OUString( "noAction" ) } - }; - - for ( pPtr = pArray; pPtr->nId && ( pPtr->nId != nControlAction ); ++pPtr ) - ; - - rType = pPtr->pType; - - return true; -} - -} - -// UnxFilePicker - -UnxFilePicker::UnxFilePicker( const uno::Reference<uno::XComponentContext>& ) - : UnxFilePicker_Base( m_rbHelperMtx ), - m_nFilePickerPid( -1 ), - m_nFilePickerWrite( -1 ), - m_nFilePickerRead( -1 ), - m_pNotifyThread( nullptr ), - m_pCommandThread( nullptr ), - m_pResMgr( ResMgr::CreateResMgr("fps_office") ) -{ -} - -UnxFilePicker::~UnxFilePicker() -{ - if ( m_nFilePickerPid > 0 ) - { - sendCommand( "exit" ); - waitpid( m_nFilePickerPid, nullptr, 0 ); - } - - if ( m_pCommandThread ) - { - m_pCommandThread->join(); - - delete m_pCommandThread; m_pCommandThread = nullptr; - } - - if ( m_pNotifyThread ) - { - m_pNotifyThread->exit(); - - m_pNotifyThread->join(); - - delete m_pNotifyThread; m_pNotifyThread = nullptr; - } - - if ( m_nFilePickerWrite >= 0 ) - close( m_nFilePickerWrite ); - - if ( m_nFilePickerRead >= 0 ) - close( m_nFilePickerRead ); - - delete m_pResMgr; m_pResMgr = nullptr; -} - -void SAL_CALL UnxFilePicker::addFilePickerListener( const uno::Reference<XFilePickerListener>& xListener ) -{ - OSL_ASSERT( m_pNotifyThread ); - osl::MutexGuard aGuard( m_aMutex ); - - m_pNotifyThread->addFilePickerListener( xListener ); -} - -void SAL_CALL UnxFilePicker::removeFilePickerListener( const uno::Reference<XFilePickerListener>& xListener ) -{ - OSL_ASSERT( m_pNotifyThread ); - osl::MutexGuard aGuard( m_aMutex ); - - m_pNotifyThread->removeFilePickerListener( xListener ); -} - -void SAL_CALL UnxFilePicker::setTitle( const OUString &rTitle ) -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - OUStringBuffer aBuffer( 1024 ); - - aBuffer.append( "setTitle " ); - appendEscaped( aBuffer, rTitle ); - - sendCommand( aBuffer.makeStringAndClear() ); -} - -sal_Int16 SAL_CALL UnxFilePicker::execute() -{ - checkFilePicker(); - - // this is _not_ an osl::Condition, see i#93366 - m_pCommandThread->execCondition().reset(); - - sendCommand( "exec" ); - - m_pCommandThread->execCondition().wait(); - - return m_pCommandThread->result() - ? css::ui::dialogs::ExecutableDialogResults::OK - : css::ui::dialogs::ExecutableDialogResults::CANCEL; -} - -void SAL_CALL UnxFilePicker::setMultiSelectionMode( sal_Bool bMode ) -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - if ( bMode ) - sendCommand( "setMultiSelection true" ); - else - sendCommand( "setMultiSelection false" ); -} - -void SAL_CALL UnxFilePicker::setDefaultName( const OUString &rName ) -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - OUStringBuffer aBuffer( 1024 ); - - aBuffer.append( "setDefaultName " ); - appendEscaped( aBuffer, rName ); - - sendCommand( aBuffer.makeStringAndClear() ); -} - -void SAL_CALL UnxFilePicker::setDisplayDirectory( const OUString &rDirectory ) -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - OUStringBuffer aBuffer( 1024 ); - - aBuffer.append( "setDirectory " ); - appendEscaped( aBuffer, rDirectory ); - - sendCommand( aBuffer.makeStringAndClear() ); -} - -OUString SAL_CALL UnxFilePicker::getDisplayDirectory() -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - sendCommand( "getDirectory", - m_pCommandThread->getDirectoryCondition() ); - - return m_pCommandThread->getDirectory(); -} - -uno::Sequence< OUString > SAL_CALL UnxFilePicker::getFiles() -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - sendCommand( "getFiles", - m_pCommandThread->getFilesCondition() ); - - return m_pCommandThread->getFiles(); -} - -void SAL_CALL UnxFilePicker::appendFilter( const OUString &rTitle, const OUString &rFilter ) -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - OUStringBuffer aBuffer( 1024 ); - - aBuffer.append( "appendFilter " ); - appendEscaped( aBuffer, rTitle ); - aBuffer.append( " " ); - appendEscaped( aBuffer, rFilter ); - - sendCommand( aBuffer.makeStringAndClear() ); -} - -void SAL_CALL UnxFilePicker::setCurrentFilter( const OUString &rTitle ) -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - OUStringBuffer aBuffer( 1024 ); - - aBuffer.append( "setCurrentFilter " ); - appendEscaped( aBuffer, rTitle ); - - sendCommand( aBuffer.makeStringAndClear() ); -} - -OUString SAL_CALL UnxFilePicker::getCurrentFilter() -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - sendCommand( "getCurrentFilter", - m_pCommandThread->getCurrentFilterCondition() ); - - return m_pCommandThread->getCurrentFilter(); -} - -void SAL_CALL UnxFilePicker::appendFilterGroup( const OUString &rGroupTitle, const uno::Sequence<beans::StringPair> &rFilters ) -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - OUStringBuffer aBuffer( 1024 ); - - aBuffer.append( "appendFilterGroup " ); - appendEscaped( aBuffer, rGroupTitle ); - - for ( sal_Int32 i = 0; i < rFilters.getLength(); ++i ) - { - beans::StringPair aPair = rFilters[i]; - - aBuffer.append( " " ); - appendEscaped( aBuffer, aPair.First ); - aBuffer.append( " " ); - appendEscaped( aBuffer, aPair.Second ); - } - - sendCommand( aBuffer.makeStringAndClear() ); -} - -void SAL_CALL UnxFilePicker::setValue( sal_Int16 nControlId, sal_Int16 nControlAction, const uno::Any &rValue ) -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - OUString aType; - OUString aAction; - sal_Int32 nTitleId; - - if ( controlIdInfo( nControlId, aType, nTitleId ) && controlActionInfo( nControlAction, aAction ) ) - { - OUStringBuffer aBuffer( 1024 ); - - aBuffer.append( "setValue " ); - aBuffer.append( static_cast< sal_Int32 >( nControlId ) ); - aBuffer.append( " " ); - aBuffer.append( aAction ); - - if ( aType == "checkbox" ) - { - bool bControlValue; - if ( ( rValue >>= bControlValue ) && bControlValue ) - aBuffer.append( " true" ); - else - aBuffer.append( " false" ); - } - else if ( aType == "listbox" ) - { - switch ( nControlAction ) - { - case ControlActions::ADD_ITEM: - case ControlActions::SET_HELP_URL: - { - OUString aString; - if ( rValue >>= aString ) - { - aBuffer.append( " " ); - appendEscaped( aBuffer, aString ); - } - } - break; - - case ControlActions::ADD_ITEMS: - { - uno::Sequence< OUString > aSequence; - if ( rValue >>= aSequence ) - { - for ( sal_Int32 nIdx = 0; nIdx < aSequence.getLength(); ++nIdx ) - { - aBuffer.append( " " ); - appendEscaped( aBuffer, aSequence[nIdx] ); - } - - } - } - break; - - case ControlActions::DELETE_ITEM: - case ControlActions::SET_SELECT_ITEM: - { - sal_Int32 nInt; - if ( rValue >>= nInt ) - { - aBuffer.append( " " ); - aBuffer.append( nInt ); - } - } - break; - - default: - // nothing - break; - } - } - // TODO else if push button... - - sendCommand( aBuffer.makeStringAndClear() ); - } -} - -uno::Any SAL_CALL UnxFilePicker::getValue( sal_Int16 nControlId, sal_Int16 nControlAction ) -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - OUString aAction; - - if ( controlActionInfo( nControlAction, aAction ) ) - { - OUStringBuffer aBuffer( 1024 ); - - aBuffer.append( "getValue " ); - aBuffer.append( static_cast< sal_Int32 >( nControlId ) ); - aBuffer.append( " " ); - aBuffer.append( aAction ); - - sendCommand( aBuffer.makeStringAndClear(), - m_pCommandThread->getValueCondition() ); - - return m_pCommandThread->getValue(); - } - - return uno::Any(); -} - -void SAL_CALL UnxFilePicker::enableControl( sal_Int16 nControlId, sal_Bool bEnable ) -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - OUStringBuffer aBuffer( 1024 ); - - aBuffer.append( "enableControl " ); - aBuffer.append( static_cast< sal_Int32 >( nControlId ) ); - aBuffer.appendAscii( bEnable? " true": " false" ); - - sendCommand( aBuffer.makeStringAndClear() ); -} - -void SAL_CALL UnxFilePicker::setLabel( sal_Int16 nControlId, const OUString &rLabel ) -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - OUStringBuffer aBuffer( 1024 ); - - aBuffer.append( "setLabel " ); - aBuffer.append( static_cast< sal_Int32 >( nControlId ) ); - aBuffer.append( " " ); - appendEscaped( aBuffer, rLabel ); - - sendCommand( aBuffer.makeStringAndClear() ); -} - -OUString SAL_CALL UnxFilePicker::getLabel(sal_Int16 /*nControlId*/) -{ - // FIXME getLabel() is not yet implemented - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - // TODO return m_pImpl->getLabel(nControlId); - return OUString(); -} - -/* TODO -uno::Sequence<sal_Int16> SAL_CALL UnxFilePicker::getSupportedImageFormats() - throw( uno::RuntimeException ) -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - return m_pImpl->getSupportedImageFormats(); -} - -sal_Int32 SAL_CALL UnxFilePicker::getTargetColorDepth() - throw( uno::RuntimeException ) -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - return m_pImpl->getTargetColorDepth(); -} - -sal_Int32 SAL_CALL UnxFilePicker::getAvailableWidth() - throw( uno::RuntimeException ) -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - return m_pImpl->getAvailableWidth(); -} - -sal_Int32 SAL_CALL UnxFilePicker::getAvailableHeight() - throw( uno::RuntimeException ) -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - return m_pImpl->getAvailableHeight(); -} - -void SAL_CALL UnxFilePicker::setImage( sal_Int16 aImageFormat, const uno::Any &rImage ) - throw( lang::IllegalArgumentException, uno::RuntimeException ) -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - m_pImpl->setImage( aImageFormat, aImage ); -} - -sal_Bool SAL_CALL UnxFilePicker::setShowState( sal_Bool bShowState ) - throw( uno::RuntimeException ) -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - return m_pImpl->setShowState( bShowState ); -} - -sal_Bool SAL_CALL UnxFilePicker::getShowState() - throw( uno::RuntimeException ) -{ - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - return m_pImpl->getShowState(); -} -*/ - -void SAL_CALL UnxFilePicker::initialize( const uno::Sequence<uno::Any> &rArguments ) -{ - initFilePicker(); - - // parameter checking - uno::Any aAny; - if ( 0 == rArguments.getLength( ) ) - throw lang::IllegalArgumentException( - "no arguments", - static_cast< XFilePicker2* >( this ), 1 ); - - aAny = rArguments[0]; - - if ( ( aAny.getValueType() != cppu::UnoType<sal_Int16>::get()) && ( aAny.getValueType() != cppu::UnoType<sal_Int8>::get()) ) - throw lang::IllegalArgumentException( - "invalid argument type", - static_cast< XFilePicker2* >( this ), 1 ); - - sal_Int16 templateId = -1; - aAny >>= templateId; - - OUString aTypeOpen( "setType \"open\"" ); - OUString aTypeSaveAs( "setType \"save\"" ); - - switch ( templateId ) - { - case FILEOPEN_SIMPLE: - sendCommand( aTypeOpen ); - break; - - case FILESAVE_SIMPLE: - sendCommand( aTypeSaveAs ); - break; - - case FILESAVE_AUTOEXTENSION_PASSWORD: - sendCommand( aTypeSaveAs ); - - sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION ); - sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD ); - break; - - case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS: - sendCommand( aTypeSaveAs ); - - sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION ); - sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD ); - sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS ); - break; - - case FILESAVE_AUTOEXTENSION_SELECTION: - sendCommand( aTypeSaveAs ); - - sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION ); - sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_SELECTION ); - break; - - case FILESAVE_AUTOEXTENSION_TEMPLATE: - sendCommand( aTypeSaveAs ); - - sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION ); - sendAppendControlCommand( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE ); - break; - - case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE: - sendCommand( aTypeOpen ); - - sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_LINK ); - sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW ); - sendAppendControlCommand( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE ); - break; - - case FILEOPEN_PLAY: - sendCommand( aTypeOpen ); - - sendAppendControlCommand( ExtendedFilePickerElementIds::PUSHBUTTON_PLAY ); - break; - - case FILEOPEN_LINK_PLAY: - sendCommand( aTypeOpen ); - - sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_LINK ); - sendAppendControlCommand( ExtendedFilePickerElementIds::PUSHBUTTON_PLAY ); - break; - - case FILEOPEN_READONLY_VERSION: - sendCommand( aTypeOpen ); - - sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_READONLY ); - sendAppendControlCommand( ExtendedFilePickerElementIds::LISTBOX_VERSION ); - break; - - case FILEOPEN_LINK_PREVIEW: - sendCommand( aTypeOpen ); - - sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_LINK ); - sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW ); - break; - - case FILESAVE_AUTOEXTENSION: - sendCommand( aTypeSaveAs ); - - sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION ); - break; - - case FILEOPEN_PREVIEW: - sendCommand( aTypeOpen ); - - sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW ); - break; - - default: - throw lang::IllegalArgumentException( - "Unknown template", - static_cast< XFilePicker2* >( this ), - 1 ); - } -} - -void SAL_CALL UnxFilePicker::cancel() -{ - // FIXME cancel() is not implemented - checkFilePicker(); - ::osl::MutexGuard aGuard( m_aMutex ); - - // TODO m_pImpl->cancel(); -} - -void SAL_CALL UnxFilePicker::disposing( const lang::EventObject &rEvent ) -{ - uno::Reference<XFilePickerListener> xFilePickerListener( rEvent.Source, uno::UNO_QUERY ); - - if ( xFilePickerListener.is() ) - removeFilePickerListener( xFilePickerListener ); -} - -OUString SAL_CALL UnxFilePicker::getImplementationName() -{ - return OUString( FILE_PICKER_IMPL_NAME ); -} - -sal_Bool SAL_CALL UnxFilePicker::supportsService( const OUString& ServiceName ) -{ - return cppu::supportsService(this, ServiceName); -} - -uno::Sequence< OUString > SAL_CALL UnxFilePicker::getSupportedServiceNames() -{ - return FilePicker_getSupportedServiceNames(); -} - -void UnxFilePicker::initFilePicker() -{ - int aFiledesStdin[2], aFiledesStdout[2]; - if ( pipe( aFiledesStdin ) < 0 || pipe( aFiledesStdout ) < 0 ) - return; - - m_nFilePickerPid = fork(); - if ( m_nFilePickerPid < 0 ) - return; - - if ( m_nFilePickerPid == 0 ) - { - // Child... - close( aFiledesStdin[1] ); // write end of the pipe - dup2( aFiledesStdin[0], 0 ); - close( aFiledesStdin[0] ); - - close( aFiledesStdout[0] ); // read end of the pipe - dup2( aFiledesStdout[1], 1 ); - close( aFiledesStdout[1] ); - -#if OSL_DEBUG_LEVEL == 0 - int nRedirect = open( "/dev/null", O_WRONLY ); - if( nRedirect != -1 ) - { - dup2( nRedirect, 2 ); - } -#endif - - // The executable name -#if ENABLE_TDE - OUString helperurl("${ORIGIN}/tdefilepicker"); -#else // ENABLE_TDE - OUString helperurl("${ORIGIN}/kdefilepicker"); -#endif // ENABLE_TDE - rtl::Bootstrap::expandMacros( helperurl ); - OUString helperpath; - osl::FileBase::getSystemPathFromFileURL( helperurl, helperpath ); - OString helper( OUStringToOString( helperpath, osl_getThreadTextEncoding())); - - // ID of the main window - const int nIdLen = 20; - char pWinId[nIdLen] = "0"; - - // TODO pass here the real parent (not possible for system dialogs - // yet), and default to GetDefDialogParent() only when the real parent - // is nullptr - vcl::Window *pParentWin = Application::GetDefDialogParent(); - if ( pParentWin ) - { - const SystemEnvData* pSysData = pParentWin->GetSystemData(); - if ( pSysData ) - { - snprintf( pWinId, nIdLen, "%ld", pSysData->aWindow ); // unx only - pWinId[nIdLen-1] = 0; - } - } - - // Execute the fpicker implementation - execlp( helper.getStr(), helper.getStr(), "--winid", pWinId, nullptr ); - - // Error, finish the child - exit( -1 ); - } - - // Parent continues - close( aFiledesStdin[0] ); - m_nFilePickerWrite = aFiledesStdin[1]; - - close( aFiledesStdout[1] ); - m_nFilePickerRead = aFiledesStdout[0]; - - // Create the notify thread - if ( !m_pNotifyThread ) - m_pNotifyThread = new UnxFilePickerNotifyThread( this ); - - // Create the command thread - if ( !m_pCommandThread ) - m_pCommandThread = new UnxFilePickerCommandThread( m_pNotifyThread, m_nFilePickerRead ); - - // Start the threads - m_pNotifyThread->create(); - m_pCommandThread->create(); - - return; -} - -void UnxFilePicker::checkFilePicker() -{ - if ( m_nFilePickerPid > 0 ) - { - // TODO check if external file picker is running - } - else - { - throw uno::RuntimeException( - "the external file picker does not run", - *this ); - } -} - -void UnxFilePicker::sendCommand( const OUString &rCommand ) -{ - if ( m_nFilePickerWrite < 0 ) - return; - - OString aUtfString = OUStringToOString( rCommand + "\n", RTL_TEXTENCODING_UTF8 ); - -#if OSL_DEBUG_LEVEL > 0 - ::std::cerr << "UnxFilePicker sent: \"" << aUtfString.getStr() << "\"" << ::std::endl; -#endif - - (void)write( m_nFilePickerWrite, aUtfString.getStr(), aUtfString.getLength() ); -} - -void UnxFilePicker::sendCommand( const OUString &rCommand, ::osl::Condition &rCondition ) -{ - rCondition.reset(); - - sendCommand( rCommand ); - - rCondition.wait(); -} - -void UnxFilePicker::sendAppendControlCommand( sal_Int16 nControlId ) -{ - OUString aType; - sal_Int32 nTitleId; - - if ( controlIdInfo( nControlId, aType, nTitleId ) ) - { - OUStringBuffer aBuffer( 1024 ); - - aBuffer.append( "appendControl " ); - aBuffer.append( static_cast< sal_Int32 >( nControlId ) ); - aBuffer.append( " " ); - appendEscaped( aBuffer, aType ); - aBuffer.append( " " ); - appendEscaped( aBuffer, m_pResMgr? ResId(nTitleId, *m_pResMgr).toString(): OUString() ); - - sendCommand( aBuffer.makeStringAndClear() ); - } -} - -uno::Sequence< OUString > SAL_CALL UnxFilePicker::getSelectedFiles() -{ - return getFiles(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/kde/UnxFilePicker.hxx b/vcl/unx/kde/UnxFilePicker.hxx deleted file mode 100644 index 8d9f2627c07c..000000000000 --- a/vcl/unx/kde/UnxFilePicker.hxx +++ /dev/null @@ -1,165 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_VCL_UNX_KDE_UNXFILEPICKER_HXX -#define INCLUDED_VCL_UNX_KDE_UNXFILEPICKER_HXX - -#include <cppuhelper/compbase.hxx> -#include <osl/conditn.hxx> -#include <osl/mutex.hxx> -#include <rtl/ustrbuf.hxx> - -#include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/ui/dialogs/XFilePicker3.hpp> -#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> - -#include <list> - -class UnxFilePickerCommandThread; -class UnxFilePickerNotifyThread; -class ResMgr; - -class UnxFilePickerDummy -{ -protected: - osl::Mutex m_aMutex; - osl::Mutex m_rbHelperMtx; -}; - -typedef ::cppu::WeakComponentImplHelper< - css::ui::dialogs::XFilePicker3, - css::ui::dialogs::XFilePickerControlAccess, -// TODO css::ui::dialogs::XFilePreview, - css::lang::XInitialization, - css::lang::XServiceInfo > UnxFilePicker_Base; - -class UnxFilePicker : - public UnxFilePickerDummy, - public UnxFilePicker_Base -{ -protected: - - pid_t m_nFilePickerPid; - int m_nFilePickerWrite; // (kde|...)filepicker gets it as stdin - int m_nFilePickerRead; // (kde|...)filepicker gets it as stdout - - UnxFilePickerNotifyThread *m_pNotifyThread; - UnxFilePickerCommandThread *m_pCommandThread; - - ResMgr *m_pResMgr; - -public: - explicit UnxFilePicker( const css::uno::Reference< css::uno::XComponentContext >& ); - virtual ~UnxFilePicker() override; - - // XComponent - - using cppu::WeakComponentImplHelperBase::disposing; - - // XFilePickerNotifier - - virtual void SAL_CALL addFilePickerListener( const css::uno::Reference< css::ui::dialogs::XFilePickerListener >& xListener ) override; - virtual void SAL_CALL removeFilePickerListener( const css::uno::Reference< css::ui::dialogs::XFilePickerListener >& xListener ) override; - - // XExecutableDialog functions - - virtual void SAL_CALL setTitle( const OUString &rTitle ) override; - virtual sal_Int16 SAL_CALL execute() override; - - // XFilePicker functions - - virtual void SAL_CALL setMultiSelectionMode( sal_Bool bMode ) override; - virtual void SAL_CALL setDefaultName( const OUString &rName ) override; - virtual void SAL_CALL setDisplayDirectory( const OUString &rDirectory ) override; - virtual OUString SAL_CALL getDisplayDirectory() override; - virtual css::uno::Sequence< OUString > SAL_CALL getFiles() override; - - // XFilterManager functions - - virtual void SAL_CALL appendFilter( const OUString &rTitle, const OUString &rFilter ) override; - virtual void SAL_CALL setCurrentFilter( const OUString &rTitle ) override; - virtual OUString SAL_CALL getCurrentFilter() override; - - // XFilterGroupManager functions - - virtual void SAL_CALL appendFilterGroup( const OUString &rGroupTitle, const css::uno::Sequence< css::beans::StringPair > &rFilters ) override; - - // XFilePickerControlAccess functions - - virtual void SAL_CALL setValue( sal_Int16 nControlId, sal_Int16 nControlAction, const css::uno::Any &rValue ) override; - virtual css::uno::Any SAL_CALL getValue( sal_Int16 nControlId, sal_Int16 nControlAction ) override; - virtual void SAL_CALL enableControl( sal_Int16 nControlId, sal_Bool bEnable ) override; - virtual void SAL_CALL setLabel( sal_Int16 nControlId, const OUString &rLabel ) override; - virtual OUString SAL_CALL getLabel( sal_Int16 nControlId ) override; - - /* TODO XFilePreview - - virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats( ) throw (css::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getTargetColorDepth( ) throw (css::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getAvailableWidth( ) throw (css::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getAvailableHeight( ) throw (css::uno::RuntimeException); - virtual void SAL_CALL setImage( sal_Int16 aImageFormat, const css::uno::Any &rImage ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); - virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ) throw (css::uno::RuntimeException); - virtual sal_Bool SAL_CALL getShowState( ) throw (css::uno::RuntimeException); - */ - - // XFilePicker2 - - virtual css::uno::Sequence< OUString > SAL_CALL getSelectedFiles() override; - - // XInitialization - - virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any > &rArguments ) override; - - // XCancellable - - virtual void SAL_CALL cancel( ) override; - - // XEventListener - - virtual void SAL_CALL disposing( const css::lang::EventObject &rEvent ); - - // XServiceInfo - - virtual OUString SAL_CALL getImplementationName() override; - virtual sal_Bool SAL_CALL supportsService( const OUString &rServiceName ) override; - virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - -private: - UnxFilePicker( const UnxFilePicker& ) = delete; - UnxFilePicker& operator=( const UnxFilePicker& ) = delete; - -protected: - void initFilePicker(); - void checkFilePicker(); - - // Async sendCommand - void sendCommand( const OUString &rCommand ); - // Synchronized sendCommand - void sendCommand( const OUString &rCommand, ::osl::Condition &rCondition ); - -private: - void sendAppendControlCommand( sal_Int16 nControlId ); -}; - -#endif // INCLUDED_VCL_UNX_KDE_UNXFILEPICKER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/kde/UnxNotifyThread.cxx b/vcl/unx/kde/UnxNotifyThread.cxx deleted file mode 100644 index 583fae056486..000000000000 --- a/vcl/unx/kde/UnxNotifyThread.cxx +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <UnxNotifyThread.hxx> -#include <UnxFilePicker.hxx> - -using namespace ::com::sun::star; - -// UnxFilePickerNotifyThread - -UnxFilePickerNotifyThread::UnxFilePickerNotifyThread( UnxFilePicker *pUnxFilePicker ) - : m_pUnxFilePicker( pUnxFilePicker ), - m_bExit( false ), - m_eNotifyType( Nothing ), - m_nControlId( 0 ) -{ -} - -void SAL_CALL UnxFilePickerNotifyThread::addFilePickerListener( const uno::Reference< ui::dialogs::XFilePickerListener >& xListener ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - m_xListener = xListener; -} - -void SAL_CALL UnxFilePickerNotifyThread::removeFilePickerListener( const uno::Reference< ui::dialogs::XFilePickerListener >& /*xListener*/ ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - m_xListener.clear(); -} - -void SAL_CALL UnxFilePickerNotifyThread::exit() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - m_bExit = true; - - m_aExitCondition.reset(); - m_aNotifyCondition.set(); - - m_aExitCondition.wait(); -} - -void SAL_CALL UnxFilePickerNotifyThread::fileSelectionChanged() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - m_eNotifyType = FileSelectionChanged; - m_nControlId = 0; - - m_aNotifyCondition.set(); -} - -void SAL_CALL UnxFilePickerNotifyThread::run() -{ - osl_setThreadName("UnxFilePickerNotifyThread"); - - do { - m_aNotifyCondition.reset(); - m_aNotifyCondition.wait(); - - if ( m_xListener.is() && m_pUnxFilePicker ) - { - ::osl::MutexGuard aGuard( m_aMutex ); - - ui::dialogs::FilePickerEvent aEvent( *m_pUnxFilePicker, m_nControlId ); - - switch ( m_eNotifyType ) - { - case FileSelectionChanged: - m_xListener->fileSelectionChanged( aEvent ); - break; - - // TODO More to come... - - default: - // nothing - break; - } - } - } while ( !m_bExit ); - - m_aExitCondition.set(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/kde/UnxNotifyThread.hxx b/vcl/unx/kde/UnxNotifyThread.hxx deleted file mode 100644 index ca029d756a62..000000000000 --- a/vcl/unx/kde/UnxNotifyThread.hxx +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_VCL_UNX_KDE_UNXNOTIFYTHREAD_HXX -#define INCLUDED_VCL_UNX_KDE_UNXNOTIFYTHREAD_HXX - -#include <com/sun/star/ui/dialogs/XFilePickerListener.hpp> -#include <com/sun/star/uno/Reference.hxx> - -#include <osl/conditn.hxx> -#include <osl/mutex.hxx> -#include <osl/thread.hxx> - -class UnxFilePicker; - -class UnxFilePickerNotifyThread : public ::osl::Thread -{ -protected: - enum NotifyType - { - Nothing = 0, - FileSelectionChanged - // TODO More to come... - }; - - UnxFilePicker *m_pUnxFilePicker; - - ::osl::Mutex m_aMutex; - - css::uno::Reference< css::ui::dialogs::XFilePickerListener > m_xListener; - - bool m_bExit; - ::osl::Condition m_aExitCondition; - - NotifyType m_eNotifyType; - ::osl::Condition m_aNotifyCondition; - sal_Int16 m_nControlId; - -public: - UnxFilePickerNotifyThread( UnxFilePicker *pUnxFilePicker ); - - virtual void SAL_CALL addFilePickerListener( const css::uno::Reference< css::ui::dialogs::XFilePickerListener >& xListener ); - virtual void SAL_CALL removeFilePickerListener( const css::uno::Reference< css::ui::dialogs::XFilePickerListener >& xListener ); - - void SAL_CALL exit(); - - void SAL_CALL fileSelectionChanged(); - /* TODO - void SAL_CALL directoryChanged( css::ui::dialogs::FilePickerEvent aEvent ); - OUString SAL_CALL helpRequested( css::ui::dialogs::FilePickerEvent aEvent ) const; - void SAL_CALL controlStateChanged( css::ui::dialogs::FilePickerEvent aEvent ); - void SAL_CALL dialogSizeChanged( ); - */ - -protected: - virtual void SAL_CALL run() override; -}; - -#endif // INCLUDED_VCL_UNX_KDE_UNXNOTIFYTHREAD_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/kde/fpicker/kdecommandthread.cxx b/vcl/unx/kde/fpicker/kdecommandthread.cxx deleted file mode 100644 index 241f5a8996ab..000000000000 --- a/vcl/unx/kde/fpicker/kdecommandthread.cxx +++ /dev/null @@ -1,185 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <cstddef> - -#include <kdecommandthread.hxx> - -#include <config_vclplug.h> - -#if ENABLE_TDE -#include <tqstringlist.h> -#include <tdeapplication.h> -#else // ENABLE_TDE -#include <qstringlist.h> -#include <kapplication.h> -#endif // ENABLE_TDE - -#if OSL_DEBUG_LEVEL > 1 -#include <iostream> -#endif - -// CommandEvent - -KDECommandEvent::KDECommandEvent( const QString &qCommand, QStringList *pStringList ) - : QCustomEvent( TypeId, pStringList ), - m_eCommand( Unknown ) -{ - struct { - const char *pName; - CommandEventType eType; - } *pIdx, pMapping[] = - { - { "appendControl", AppendControl }, - { "enableControl", EnableControl }, - { "getValue", GetValue }, - { "setValue", SetValue }, - { "appendFilter", AppendFilter }, - { "appendFilterGroup", AppendFilterGroup }, - { "getCurrentFilter", GetCurrentFilter }, - { "setCurrentFilter", SetCurrentFilter }, - { "getDirectory", GetDirectory }, - { "setDirectory", SetDirectory }, - { "getFiles", GetFiles }, - { "getSelectedFiles", GetSelectedFiles }, - { "setTitle", SetTitle }, - { "setType", SetType }, - { "setDefaultName", SetDefaultName }, - { "setMultiSelection", SetMultiSelection }, - { "exec", Exec }, - { nullptr, Unknown } - }; - - for ( pIdx = pMapping; pIdx->pName && qCommand != pIdx->pName; ++pIdx ) - ; - - m_eCommand = pIdx->eType; -} - -// CommandThread - -namespace { - -QStringList* tokenize( const QString &rString ) -{ - // Commands look like: - // command arg1 arg2 arg3 ... - // Args may be enclosed in '"', if they contain spaces. - - QStringList *pList = new QStringList(); - - QString qBuffer; - qBuffer.reserve( 1024 ); - - const QChar *pUnicode = rString.unicode(); - const QChar *pEnd = pUnicode + rString.length(); - bool bQuoted = false; - - for ( ; pUnicode != pEnd; ++pUnicode ) - { - if ( *pUnicode == '\\' ) - { - ++pUnicode; - if ( pUnicode != pEnd ) - { - if ( *pUnicode == 'n' ) - qBuffer.append( '\n' ); - else - qBuffer.append( *pUnicode ); - } - } - else if ( *pUnicode == '"' ) - bQuoted = !bQuoted; - else if ( *pUnicode == ' ' && !bQuoted ) - { - pList->push_back( qBuffer ); - qBuffer.setLength( 0 ); - } - else - qBuffer.append( *pUnicode ); - } - pList->push_back( qBuffer ); - - return pList; -} - -} - -KDECommandThread::KDECommandThread( QWidget *pObject ) - : m_pObject( pObject ) -{ -} - -KDECommandThread::~KDECommandThread() -{ -} - -void KDECommandThread::run() -{ - QTextIStream qStream( stdin ); - qStream.setEncoding( QTextStream::UnicodeUTF8 ); - - QString qLine; - bool bQuit = false; - while ( !bQuit && !qStream.atEnd() ) - { - qLine = qStream.readLine(); - handleCommand( qLine, bQuit ); - } -} - -void KDECommandThread::handleCommand( const QString &rString, bool &bQuit ) -{ - QMutexLocker qMutexLocker( &m_aMutex ); - -#if OSL_DEBUG_LEVEL > 1 - ::std::cerr << "kdefilepicker received: " << rString.latin1() << ::std::endl; -#endif - - bQuit = false; - QStringList *pTokens = tokenize( rString ); - - if ( !pTokens ) - return; - if ( pTokens->empty() ) - { - delete pTokens; pTokens = nullptr; - return; - } - - QString qCommand = pTokens->front(); - pTokens->pop_front(); -#if OSL_DEBUG_LEVEL > 1 - ::std::cerr << "kdefilepicker first command: " << qCommand.latin1() << ::std::endl; -#endif - - if ( qCommand == "exit" ) - { - bQuit = true; - QApplication::exit(); - kapp->wakeUpGuiThread(); -#if OSL_DEBUG_LEVEL > 1 - ::std::cerr << "kdefilepicker: exiting" << ::std::endl; -#endif - } - else - QApplication::postEvent( m_pObject, new KDECommandEvent( qCommand, pTokens ) ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/kde/fpicker/kdecommandthread.hxx b/vcl/unx/kde/fpicker/kdecommandthread.hxx deleted file mode 100644 index 374d74a4f1cb..000000000000 --- a/vcl/unx/kde/fpicker/kdecommandthread.hxx +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_VCL_UNX_KDE_FPICKER_KDECOMMANDTHREAD_HXX -#define INCLUDED_VCL_UNX_KDE_FPICKER_KDECOMMANDTHREAD_HXX - -#include <sal/config.h> - -#include <config_vclplug.h> -#include <sal/types.h> - -#if ENABLE_TDE -#include <shell/tde_defines.h> -#endif // ENABLE_TDE - -#if ENABLE_TDE -#include <tqevent.h> -#include <tqmutex.h> -#include <tqthread.h> -#else // ENABLE_TDE -#include <qevent.h> -#include <qmutex.h> -#include <qthread.h> -#endif // ENABLE_TDE - -class KDECommandEvent : public QCustomEvent -{ -public: - enum CommandEventType { - Unknown = 0, - - AppendControl, - EnableControl, - GetValue, - SetValue, - - AppendFilter, - AppendFilterGroup, - UpdateFilters, - GetCurrentFilter, - SetCurrentFilter, - - GetDirectory, - SetDirectory, - - GetFiles, - GetSelectedFiles, - - SetTitle, - SetType, - SetDefaultName, - SetMultiSelection, - - Exec - }; - static const QEvent::Type TypeId = (QEvent::Type) ( (int) QEvent::User + 42 /*random magic value*/ ); - -protected: - CommandEventType m_eCommand; - -public: - KDECommandEvent( const QString &qCommand, QStringList *pStringList ); - - CommandEventType command() const { return m_eCommand; } - QStringList* stringList() { return static_cast< QStringList* >( data() ); } -}; - -class KDECommandThread : public QThread -{ -protected: - QObject *m_pObject; - - QMutex m_aMutex; - -public: - KDECommandThread( QWidget *pObject ); - virtual ~KDECommandThread() override; - - virtual void run() override; - -protected: - void handleCommand( const QString &rString, bool &bQuit ); -}; - -#endif // INCLUDED_VCL_UNX_KDE_FPICKER_KDECOMMANDTHREAD_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/kde/fpicker/kdefilepicker.cxx b/vcl/unx/kde/fpicker/kdefilepicker.cxx deleted file mode 100644 index 1f7b7d693d39..000000000000 --- a/vcl/unx/kde/fpicker/kdefilepicker.cxx +++ /dev/null @@ -1,806 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <cstddef> - -#include <kdecommandthread.hxx> -#include <kdefilepicker.hxx> - -#include <config_vclplug.h> - -#if ENABLE_TDE - -#include <tqcheckbox.h> -#include <tqcombobox.h> -#include <tqgrid.h> -#include <tqhbox.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqobjectlist.h> -#include <tqpushbutton.h> -#include <tqregexp.h> -#include <tqvbox.h> - -#ifdef TQT_NO_EMIT -#define emit -#endif - -#include <tdeversion.h> -#include <tdediroperator.h> -#include <tdefiledialog.h> -#include <tdefilefiltercombo.h> -#include <tdeio/netaccess.h> -#include <tdelocale.h> -#include <tdemessagebox.h> -#include <tdetempfile.h> - -#else // ENABLE_TDE - -#include <qcheckbox.h> -#include <qcombobox.h> -#include <qgrid.h> -#include <qhbox.h> -#include <qlabel.h> -#include <qlayout.h> -#include <qobjectlist.h> -#include <qpushbutton.h> -#include <qregexp.h> -#include <qvbox.h> - -#ifdef QT_NO_EMIT -#define emit -#endif - -#include <kdeversion.h> -#include <kdiroperator.h> -#include <kfiledialog.h> -#include <kfilefiltercombo.h> -#include <kio/netaccess.h> -#include <klocale.h> -#include <kmessagebox.h> -#include <ktempfile.h> - -#endif // ENABLE_TDE - -#if ENABLE_TDE -#define QCheckBox_String "TQCheckBox" -#define QComboBox_String "TQComboBox" -#else // ENABLE_TDE -#define QCheckBox_String "QCheckBox" -#define QComboBox_String "QComboBox" -#endif // ENABLE_TDE - -#include <algorithm> -#include <iostream> - -namespace { - -bool isSupportedProtocol( const QString &rProtocol ) -{ - // TODO Get this information directly from OOo - const char * pOOoProtocols[] = { "", "smb", "ftp", "http", "file", "mailto", - "vnd.sun.star.webdav", "vnd.sun.star.webdavs", "news", "private", "vnd.sun.star.help", - "https", "slot", "macro", "javascript", "imap", "pop3", "data", - "cid", "out", "vnd.sun.star.hier", "vim", - ".uno", ".component", "vnd.sun.star.pkg", "ldap", "db", - "vnd.sun.star.cmd", "vnd.sun.star.script", - "telnet", - nullptr }; - - for ( const char **pIndex = pOOoProtocols; *pIndex != nullptr; ++pIndex ) - { - if ( rProtocol == *pIndex ) - return true; - } - - // TODO gnome-vfs bits here - - return false; -} - -void sendCommand( const QString &rCommand ) -{ -#if OSL_DEBUG_LEVEL > 1 - ::std::cerr << "kdefilepicker sent: " << rCommand.latin1() << ::std::endl; -#endif - - //m_aOutputStream << rCommand << endl; - ::std::cout << rCommand.utf8() << ::std::endl; -} - -void appendEscaped( QString &rBuffer, const QString &rString ) -{ - const QChar *pUnicode = rString.unicode(); - const QChar *pEnd = pUnicode + rString.length(); - - rBuffer.append( '"' ); - for ( ; pUnicode != pEnd; ++pUnicode ) - { - if ( *pUnicode == '\\' ) - rBuffer.append( "\\\\" ); - else if ( *pUnicode == '"' ) - rBuffer.append( "\\\"" ); - else if ( *pUnicode == '\n' ) - rBuffer.append( "\\\n" ); - else - rBuffer.append( *pUnicode ); - } - rBuffer.append( '"' ); -} - -QString escapeString( const QString &rString ) -{ - QString qString; - qString.reserve( 2*rString.length() + 2 ); // every char escaped + quotes - - appendEscaped( qString, rString ); - - return qString; -} - -} - -// KDEFileDialog - -KDEFileDialog::KDEFileDialog( const QString &startDir, const QString &filter, - QWidget *parent, const char *name ) - : KFileDialog( startDir, filter, parent, name, true, m_pCustomWidget = new QVBox() ), - m_pCombosAndButtons( new QHBox( m_pCustomWidget ) ), - m_pLabels( new QVBox( m_pCombosAndButtons ) ), - m_pComboBoxes( new QVBox( m_pCombosAndButtons ) ), - m_pPushButtons( new QVBox( m_pCombosAndButtons ) ), - m_pCheckBoxes( new QGrid( 2, m_pCustomWidget ) ), - m_bIsSave( false ), - m_bIsExecuting( false ), - m_bCanNotifySelection( true ) -{ -#if ENABLE_TDE - connect( this, SIGNAL( fileHighlighted( const TQString & ) ), - this, SLOT( fileHighlightedCommand( const TQString & ) ) ); -#else // ENABLE_TDE - connect( this, SIGNAL( fileHighlighted( const QString & ) ), - this, SLOT( fileHighlightedCommand( const QString & ) ) ); -#endif // ENABLE_TDE - - connect( this, SIGNAL( selectionChanged() ), - this, SLOT( selectionChangedCommand() ) ); - - m_pCustomWidget->setSpacing( KDialog::spacingHint() ); - m_pCombosAndButtons->setSpacing( KDialog::spacingHint() ); - - updateCustomWidgetLayout(); -} - -KDEFileDialog::~KDEFileDialog() -{ -} - -void KDEFileDialog::resizeEvent( QResizeEvent *pEvent ) -{ - KFileDialog::resizeEvent( pEvent ); - - updateCustomWidgetLayout(); -} - -void KDEFileDialog::showEvent( QShowEvent *pEvent ) -{ - KFileDialog::showEvent( pEvent ); - - updateCustomWidgetLayout(); -} - -void KDEFileDialog::updateCustomWidgetLayout() -{ - QPoint qReferencePoint = filterWidget->mapTo( this, QPoint( 0, 0 ) ); - QPoint qCustomPoint = m_pCustomWidget->mapTo( this, QPoint( 0, 0 ) ); - - int nLeft = qReferencePoint.x() - qCustomPoint.x(); - int nRight = m_pCustomWidget->width() - filterWidget->width() - nLeft; - - nLeft -= KDialog::spacingHint(); - nRight -= KDialog::spacingHint(); - m_pLabels->setFixedWidth( ( nLeft > 0 )? nLeft: 80 ); - // FIXME The following call sets the width of m_pPushButtons all right, - // but it also increases the width of m_pComboBoxes rapidly. Can we do - // anything about it? - m_pPushButtons->setFixedWidth( ( nRight > 0 )? nRight: 100 ); -} - -void KDEFileDialog::customEvent( QCustomEvent *pEvent ) -{ - if ( pEvent && pEvent->type() == KDECommandEvent::TypeId ) - { - KDECommandEvent *pCommandEvent = static_cast< KDECommandEvent* >( pEvent ); - QStringList *pStringList = pCommandEvent->stringList(); - - int nListSize = -1; - if ( pStringList ) - nListSize = pStringList->size(); - - switch ( pCommandEvent->command() ) - { - case KDECommandEvent::AppendControl: - if ( nListSize >= 3 ) - { - appendControl( (*pStringList)[0], (*pStringList)[1], (*pStringList)[2] ); - } - break; - case KDECommandEvent::EnableControl: - if ( nListSize >= 2 ) - { - enableControl( (*pStringList)[0], (*pStringList)[1] ); - } - break; - case KDECommandEvent::GetValue: - if ( nListSize >= 2 ) - { - getValue( (*pStringList)[0], (*pStringList)[1] ); - } - break; - case KDECommandEvent::SetValue: - if ( nListSize >= 2 ) - { - QStringList qStringList = (*pStringList); - qStringList.pop_front(); - qStringList.pop_front(); - - setValue( (*pStringList)[0], (*pStringList)[1], qStringList ); - } - break; - case KDECommandEvent::AppendFilter: - if ( nListSize >= 2 ) - { - appendFilter( (*pStringList)[0], (*pStringList)[1] ); - - // update the filters widget - setFilter( filters() ); - } - break; - case KDECommandEvent::AppendFilterGroup: - if ( nListSize >= 1 ) - { - QStringList::const_iterator it = pStringList->begin(); - ++it; // We ignore the filter group name - - while ( it != pStringList->end() ) - { - QString qTitle = *it; - ++it; - if ( it != pStringList->end() ) - { - appendFilter( qTitle, (*it) ); - ++it; - } - } - - // update the filters widget - setFilter( filters() ); - } - break; - case KDECommandEvent::GetCurrentFilter: - { - QString qCurrentFilter = filterWidget->currentText(); - sendCommand( "currentFilter " + escapeString( qCurrentFilter ) ); - } - break; - case KDECommandEvent::SetCurrentFilter: - if ( nListSize >= 1 ) - { - static_cast< KDEFileFilterComboHack* >( filterWidget )->setCurrentFilter( pStringList->front() ); - } - break; - case KDECommandEvent::GetDirectory: - { - QString qDirectory = baseURL().url(); - if ( qDirectory.startsWith( "file:/" ) && qDirectory.mid( 6, 1 ) != "/" ) - qDirectory.replace( "file:/", "file:///" ); - sendCommand( "currentDirectory " + escapeString( qDirectory ) ); - } - break; - case KDECommandEvent::SetDirectory: - if ( nListSize >= 1 ) - { - setURL( pStringList->front() ); - } - break; - case KDECommandEvent::GetFiles: - { - QString qString; - qString.reserve( 1024 ); - - qString.append( "files" ); - - if ( result() == QDialog::Accepted ) - { - KURL::List qList( selectedURLs() ); - for ( KURL::List::const_iterator it = qList.begin(); it != qList.end(); ++it ) - { - appendURL( qString, (*it) ); - break; // we just want the first element - } - } - else - { - // we have to return the selected files anyway - const KFileItemList *pItems = ops->selectedItems(); - for ( KFileItemListIterator it( *pItems ); it.current(); ++it ) - { - appendURL( qString, (*it)->url() ); - break; // we just want the first element - } - } - - sendCommand( qString ); - setCanNotifySelection( true ); - } - break; - case KDECommandEvent::GetSelectedFiles: - { - QString qString; - qString.reserve( 1024 ); - - qString.append( "files" ); - - if ( result() == QDialog::Accepted ) - { - KURL::List qList( selectedURLs() ); - for ( KURL::List::const_iterator it = qList.begin(); it != qList.end(); ++it ) - appendURL( qString, (*it) ); - } - else - { - // we have to return the selected files anyway - const KFileItemList *pItems = ops->selectedItems(); - for ( KFileItemListIterator it( *pItems ); it.current(); ++it ) - appendURL( qString, (*it)->url() ); - } - - sendCommand( qString ); - setCanNotifySelection( true ); - } - break; - case KDECommandEvent::SetTitle: - if ( nListSize >= 1 ) - { - setCaption( pStringList->front() ); - } - break; - case KDECommandEvent::SetType: - if ( nListSize >= 1 ) - { - QString qType( pStringList->front() ); - if ( qType == "open" ) - { - setIsSave( false ); - setCaption( i18n( "Open" ) ); - } - else if ( qType == "save" ) - { - setIsSave( true ); - setCaption( i18n( "Save As" ) ); - } - } - break; - case KDECommandEvent::SetDefaultName: - if ( nListSize >= 1 ) - { - setKeepLocation( true ); - setSelection( pStringList->front() ); - } - break; - case KDECommandEvent::SetMultiSelection: - if ( nListSize >= 1 ) - { - if ( pStringList->front() == "true" ) - setMode( KFile::Files ); - else - setMode( KFile::File ); - } - break; - case KDECommandEvent::Exec: - { - filterWidget->setEditable( false ); - setIsExecuting( true ); - bool bCanExit = false; - do { - setCanNotifySelection( true ); - exec(); - - KURL qLocalSelectedURL = mostLocalURL( selectedURL() ); - QString qProtocol( qLocalSelectedURL.protocol() ); - - if ( isSave() && result() == QDialog::Accepted ) - { - if ( qProtocol == "file" ) - { - QString qFileName( addExtension( qLocalSelectedURL.path() ) ); - bCanExit = - !QFile::exists( qFileName ) || - ( KMessageBox::warningYesNo( nullptr, - i18n( "A file named \"%1\" already exists. " - "Are you sure you want to overwrite it?" ).arg( qFileName ), - i18n( "Overwrite File?" ), - i18n( "Overwrite" ), KStdGuiItem::cancel() ) == KMessageBox::Yes ); - } - else if ( !isSupportedProtocol( qProtocol ) ) - { - KMessageBox::sorry( nullptr, - i18n( "Saving using protocol \"%1\" is not supported." ).arg( qProtocol ) ); - bCanExit = false; - } - else - bCanExit = true; - } - else if ( !isSave() && result() == QDialog::Accepted && !isSupportedProtocol( qProtocol ) ) - { - KMessageBox::information( nullptr, - i18n( "Protocol \"%1\" is supported only partially. " - "Local copy of the file will be created." ).arg( qProtocol ) ); - bCanExit = true; - } - else - bCanExit = true; - } while ( !bCanExit ); - setIsExecuting( false ); - - if ( result() == QDialog::Accepted ) - sendCommand( "accept" ); - else - sendCommand( "reject" ); - } - break; - default: - break; - } - - // FIXME Some cleanup of pEvent? delete something, etc.? - } -} - -void KDEFileDialog::appendControl( const QString &rId, const QString &rType, const QString &rTitle ) -{ - QString qLabel( rTitle ); - qLabel.replace( '~', '&' ); - - if ( rType == "checkbox" ) - { - QCheckBox *pCheckBox = new QCheckBox( qLabel, m_pCheckBoxes, rId.utf8() ); - - pCheckBox->setEnabled( true ); - pCheckBox->setChecked( false ); - } - else if ( rType == "listbox" ) - { - QLabel *pComboLabel = new QLabel( qLabel, m_pLabels ); - QComboBox *pComboBox = new QComboBox( m_pComboBoxes, rId.utf8() ); - - pComboLabel->setBuddy( pComboBox ); - pComboBox->setEnabled( true ); - } - else if ( rType == "pushbutton" ) - { - QPushButton *pPushButton = new QPushButton( qLabel, m_pPushButtons, rId.utf8() ); - pPushButton->setEnabled( true ); - } -} - -QWidget* KDEFileDialog::findControl( const QString &rId ) const -{ - QObjectList *pList = m_pCustomWidget->queryList(); - QCString qName( rId.utf8() ); - QObjectList::const_iterator it = pList->begin(); - - for ( ; it != pList->end() && qName != (*it)->name(); ++it ) - ; - - QWidget *pWidget = nullptr; - if ( it != pList->end() ) - pWidget = static_cast< QWidget* >( *it ); - - delete pList; - - return pWidget; -} - -void KDEFileDialog::enableControl( const QString &rId, const QString &rValue ) -{ - QWidget *pWidget = findControl( rId ); - - if ( pWidget ) - pWidget->setEnabled( rValue.lower() == "true" ); -} - -void KDEFileDialog::getValue( const QString &rId, const QString &rAction ) -{ - QWidget *pWidget = findControl( rId ); - QString qString; - qString.reserve( 1024 ); - qString.append( "value" ); - - if ( pWidget ) - { - QCString qClassName = pWidget->className(); - if ( qClassName == QCheckBox_String ) - { - QCheckBox *pCheckBox = static_cast< QCheckBox* >( pWidget ); - - if ( pCheckBox->isChecked() ) - qString.append( " bool true" ); - else - qString.append( " bool false" ); - } - else if ( qClassName == QComboBox_String ) - { - QComboBox *pComboBox = static_cast< QComboBox* >( pWidget ); - if ( rAction == "getItems" ) - { - qString.append( " stringList" ); - for ( int nIdx = 0; nIdx < pComboBox->count(); ++nIdx ) - { - qString.append( ' ' ); - appendEscaped( qString, pComboBox->text( nIdx ) ); - } - } - else if ( rAction == "getSelectedItem" ) - { - qString.append( " string " ); - appendEscaped( qString, pComboBox->currentText() ); - } - else if ( rAction == "getSelectedItemIndex" ) - { - qString.append( " int " ); - qString.append( QString().setNum( pComboBox->currentItem() ) ); - } - // TODO getHelpURL - } - // TODO push button - } - - sendCommand( qString ); -} - -void KDEFileDialog::setValue( const QString &rId, const QString &rAction, const QStringList &rValue ) -{ - QWidget *pWidget = findControl( rId ); - - if ( pWidget ) - { - QCString qClassName = pWidget->className(); - if ( qClassName == QCheckBox_String ) - { - QCheckBox *pCheckBox = static_cast< QCheckBox* >( pWidget ); - - bool bValue = ( !rValue.isEmpty() ) && ( rValue.front().lower() == "true" ); - pCheckBox->setChecked( bValue ); - } - else if ( qClassName == QComboBox_String ) - { - QComboBox *pComboBox = static_cast< QComboBox* >( pWidget ); - if ( rAction == "addItem" ) - { - if ( !rValue.isEmpty() ) - pComboBox->insertItem( rValue.front() ); - } - else if ( rAction == "addItems" ) - { - pComboBox->insertStringList( rValue ); - } - else if ( rAction == "deleteItem" ) - { - if ( !rValue.isEmpty() ) - pComboBox->removeItem( rValue.front().toInt() ); - } - else if ( rAction == "deleteItems" ) - { - pComboBox->clear(); - } - else if ( rAction == "setSelectedItem" ) - { - if ( !rValue.isEmpty() ) - pComboBox->setCurrentItem( rValue.front().toInt() ); - } - // FIXME setHelpURL is ignored - } - // TODO push button - } -} - -void KDEFileDialog::appendFilter( const QString &rTitle, const QString &rFilter ) -{ - // Filters are separated by ';' - QString qFilter( rFilter ); - qFilter.replace( QChar( ';' ), QChar( ' ' ) ).replace( "*.*", "*" ); - - // Workaround for too wide <All formats> (*.bmp;...) entry - QString qTitle( rTitle ); - qTitle.replace( QRegExp( "^<([^>]*)> \\(.*" ), "<\\1>" ); - - m_aFilters.push_back( qMakePair( qTitle, qFilter ) ); -} - -QString KDEFileDialog::filters() const -{ - QString qString, qTmp; - bool bFirstFilter = true; - - for ( FilterList::const_iterator it = m_aFilters.begin(); it != m_aFilters.end(); ++it ) - { - if ( bFirstFilter ) - bFirstFilter = false; - else - qString.append( '\n' ); - - qString.append( (*it).second ); - qString.append( '|' ); - - qTmp = (*it).first; - qString.append( qTmp.replace( '/', "\\/" ) ); - } - - return qString; -} - -QString KDEFileDialog::addExtension( const QString &rFileName ) const -{ - if ( !isSave() ) - return rFileName; - - QString qExtension; - - QWidget *pExtensionWidget = findControl( "100" ); // CHECKBOX_AUTOEXTENSION - QCheckBox *pExtensionCB = pExtensionWidget? static_cast< QCheckBox* >( pExtensionWidget->qt_cast( QCheckBox_String ) ): nullptr; - if ( pExtensionCB && pExtensionCB->isChecked() ) - { - // FIXME: qFilter can be a MIME; we ignore it now... - QStringList qFilterList = QStringList::split( " ", currentFilter() ); - for ( QStringList::const_iterator it = qFilterList.begin(); - qExtension.isEmpty() && it != qFilterList.end(); - ++it ) - { - int nUnwanted = (*it).findRev( '*' ); - if ( nUnwanted < 0 ) - nUnwanted = (*it).findRev( '?' ); - else - nUnwanted = ::std::max( nUnwanted, (*it).find( '?', nUnwanted ) ); - - int nIdx = (*it).find( '.', ::std::max( nUnwanted, 0 ) ); - if ( nIdx >= 0 ) - qExtension = (*it).mid( nIdx ).lower(); - } - } - - if ( qExtension.isEmpty() || qExtension == "." || rFileName.endsWith( qExtension ) ) - return rFileName; - else - return rFileName + qExtension; -} - -KURL KDEFileDialog::mostLocalURL( const KURL &rURL ) const -{ -#if KDE_IS_VERSION(3,5,0) - KURL qMostLocalURL( KIO::NetAccess::mostLocalURL( rURL, const_cast<KDEFileDialog*>( this ) ) ); - if ( qMostLocalURL.isLocalFile() ) - return qMostLocalURL; - else - { - // Terrible hack to get even non-existing media:// files right - qMostLocalURL.cd( ".." ); - KURL qMostLocalPath( KIO::NetAccess::mostLocalURL( qMostLocalURL, const_cast<KDEFileDialog*>( this ) ) ); - if ( qMostLocalPath.isLocalFile() ) - { - qMostLocalPath.addPath( rURL.fileName() ); - return qMostLocalPath; - } - } -#endif - - return rURL; -} - -QString KDEFileDialog::localCopy( const QString &rFileName ) const -{ - // 106 == MIB enum for UTF-8 - KURL qLocalURL = mostLocalURL( KURL( rFileName, 106 ) ); - if ( qLocalURL.isLocalFile() ) - return qLocalURL.url(); - - int nExtensionPos = rFileName.findRev( '/' ); - if ( nExtensionPos >= 0 ) - nExtensionPos = rFileName.find( '.', nExtensionPos ); - else - nExtensionPos = rFileName.find( '.' ); - - KTempFile qTempFile( QString::null, ( nExtensionPos < 0 )? QString(): rFileName.mid( nExtensionPos ) ); - KURL qDestURL; - qDestURL.setPath( qTempFile.name() ); - - if ( !KIO::NetAccess::file_copy( rFileName, qDestURL, 0600, true ) ) - { - KMessageBox::error( nullptr, KIO::NetAccess::lastErrorString() ); - return QString::null; - } - - return qDestURL.url(); -} - -#if ENABLE_TDE -void KDEFileDialog::fileHighlightedCommand( const TQString & ) -#else // ENABLE_TDE -void KDEFileDialog::fileHighlightedCommand( const QString & ) -#endif // ENABLE_TDE -{ - if ( canNotifySelection() ) - { - sendCommand( "fileSelectionChanged" ); - setCanNotifySelection( false ); - } -} - -void KDEFileDialog::selectionChangedCommand() -{ - if ( canNotifySelection() ) - { - sendCommand( "fileSelectionChanged" ); - setCanNotifySelection( false ); - } -} - -void KDEFileDialog::appendURL( QString &rBuffer, const KURL &rURL ) -{ - // From Martin Kretzschmar: - // file:///path/to/test%E0.odt is not a valid URL from OOo's point of - // view. (?Most modern parts of?) OOo assume(s) that the URL contains only - // ASCII characters (which test%E0.odt does) and is UTF-8 after unescaping - // (which file:///path/test%E0.odt is not). - // Cf. the comment in sal/inc/osl/file.h. - // 106 == MIB enum for UTF-8 - QString qUrlStr = addExtension( rURL.url( 0, 106 ) ); - - if ( !isExecuting() && !isSupportedProtocol( rURL.protocol() ) ) - qUrlStr = localCopy( qUrlStr ); - - if ( qUrlStr.startsWith( "file:/" ) && qUrlStr.mid( 6, 1 ) != "/" ) - qUrlStr.replace( "file:/", "file:///" ); - - rBuffer.append( " " ); - if ( !qUrlStr.isEmpty() ) - appendEscaped( rBuffer, qUrlStr ); -} - -void KDEFileFilterComboHack::setCurrentFilter( const QString& filter ) -{ - setCurrentText( filter ); - filterChanged(); - - // Workaround for 'Filter name (*.blah)' vs. 'Filter name' - if ( currentText() != text( currentItem() ) ) - { - int nItem = 0; - for ( ; nItem < count() && !text( nItem ).startsWith( filter ); ++nItem ); - - if ( nItem < count() ) - setCurrentItem( nItem ); - else - setCurrentItem( 0 ); - - filterChanged(); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/kde/fpicker/kdefilepicker.hxx b/vcl/unx/kde/fpicker/kdefilepicker.hxx deleted file mode 100644 index 630b4278811c..000000000000 --- a/vcl/unx/kde/fpicker/kdefilepicker.hxx +++ /dev/null @@ -1,138 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_VCL_UNX_KDE_FPICKER_KDEFILEPICKER_HXX -#define INCLUDED_VCL_UNX_KDE_FPICKER_KDEFILEPICKER_HXX - -#include <sal/config.h> - -#include <config_vclplug.h> -#include <sal/types.h> - -#if ENABLE_TDE -#include <shell/tde_defines.h> -#endif // ENABLE_TDE - -#include <cstddef> - -#if ENABLE_TDE -#include <tdefiledialog.h> -#include <tdefilefiltercombo.h> -#else // ENABLE_TDE -#include <kfiledialog.h> -#include <kfilefiltercombo.h> -#endif // ENABLE_TDE - -class QGrid; -class QHBox; -class QVBox; - -class KDEFileDialog : public KFileDialog -{ -#if ENABLE_TDE - TQ_OBJECT -#else // ENABLE_TDE - Q_OBJECT -#endif // ENABLE_TDE - -protected: - typedef QPair< QString, QString > FilterEntry; - typedef QValueList< FilterEntry > FilterList; - - QVBox *m_pCustomWidget; - QHBox *m_pCombosAndButtons; - - QVBox *m_pLabels; - QVBox *m_pComboBoxes; - QVBox *m_pPushButtons; - - QGrid *m_pCheckBoxes; - - FilterList m_aFilters; - - /** Are we a "Save As" dialog? - * - * We cannot use KFileDialog::setOperationMode() here, because then - * it automatically adds an "Automatically select filename extension" - * check box, and completely destroys the dialog's layout - * (custom list boxes are under this check box, which looks ugly). - */ - bool m_bIsSave; - bool m_bIsExecuting; - - bool m_bCanNotifySelection; - -public: - KDEFileDialog( const QString &startDir, const QString &filter, - QWidget *parent, const char *name ); - virtual ~KDEFileDialog() override; - -protected: - virtual void resizeEvent( QResizeEvent *pEvent ) override; - virtual void showEvent( QShowEvent *pEvent ) override; - void updateCustomWidgetLayout(); - - virtual void customEvent( QCustomEvent *pEvent ) override; - -protected: - void appendControl( const QString &rId, const QString &rType, const QString &rTitle ); - QWidget* findControl( const QString &rId ) const; - void enableControl( const QString &rId, const QString &rValue ); - void getValue( const QString &rId, const QString &rAction ); - void setValue( const QString &rId, const QString &rAction, const QStringList &rValue ); - - void appendFilter( const QString &rTitle, const QString &rFilter ); - QString filters() const; - QString addExtension( const QString &rFileName ) const; - - void setIsSave( bool bIsSave ) { m_bIsSave = bIsSave; } - bool isSave() const { return m_bIsSave; } - - void setIsExecuting( bool bIsExecuting ) { m_bIsExecuting = bIsExecuting; } - bool isExecuting() const { return m_bIsExecuting; } - - KURL mostLocalURL( const KURL &rURL ) const; - QString localCopy( const QString &rFileName ) const; - - void setCanNotifySelection( bool bCanNotifySelection ) { m_bCanNotifySelection = bCanNotifySelection; } - bool canNotifySelection() const { return m_bCanNotifySelection; } - -protected slots: -// Qt3 moc does not really understand #ifdef and would process both slots, -// so the FILTER_OUT_FOO tags are used to remove some slots before moc sees them. -#if ENABLE_TDE - void fileHighlightedCommand( const TQString & ); // FILTER_OUT_TDE -#else // ENABLE_TDE - void fileHighlightedCommand( const QString & ); // FILTER_OUT_KDE -#endif // ENABLE_TDE - void selectionChangedCommand(); - -protected: - void appendURL( QString &rBuffer, const KURL &rURL ); -}; - -class KDEFileFilterComboHack : public KFileFilterCombo -{ -public: - void setCurrentFilter( const QString& filter ); -}; - -#endif // INCLUDED_VCL_UNX_KDE_FPICKER_KDEFILEPICKER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/kde/fpicker/kdefpmain.cxx b/vcl/unx/kde/fpicker/kdefpmain.cxx deleted file mode 100644 index 0031ae0e92bf..000000000000 --- a/vcl/unx/kde/fpicker/kdefpmain.cxx +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <cstddef> - -#include <kdemodalityfilter.hxx> -#include <kdefilepicker.hxx> -#include <kdecommandthread.hxx> - -#if ENABLE_TDE -#include <tqeventloop.h> -#include <tdeaboutdata.h> -#include <tdeapplication.h> -#include <tdecmdlineargs.h> -#else // ENABLE_TDE -#include <kaboutdata.h> -#include <kapplication.h> -#include <kcmdlineargs.h> -#endif // ENABLE_TDE - -#include <iostream> -#include <stdlib.h> - -#include <config_vclplug.h> - -#if ENABLE_TDE -#define THIS_DESKENV_NAME_CAP "TDE" -#define THIS_DESKENV_NAME_LOW "tde" -#else // ENABLE_TDE -#define THIS_DESKENV_NAME_CAP "KDE" -#define THIS_DESKENV_NAME_LOW "kde" -#endif // ENABLE_TDE - -#if ENABLE_TDE -#define KAboutData TDEAboutData -#define KCmdLineArgs TDECmdLineArgs -#define KCmdLineOptions TDECmdLineOptions -#define KCmdLineLastOption TDECmdLineLastOption -#define KApplication TDEApplication -#define KLocale TDELocale -#endif // ENABLE_TDE - -// Main - -static const KCmdLineOptions sOptions[] = -{ - { "winid <argument>", I18N_NOOP("Window ID to which is the fpicker modal"), "0" }, - KCmdLineLastOption -}; - -int main( int argc, char* argv[] ) -{ - // we fake the name of the application to have "LibreOffice" in the - // title - KAboutData qAboutData( "kdefilepicker", I18N_NOOP( "LibreOffice" ), - "0.1", I18N_NOOP( "kdefilepicker is an implementation of the " THIS_DESKENV_NAME_CAP " file dialog for LibreOffice." ), - KAboutData::License_LGPL, - "(c) 2004, Jan Holesovsky" ); - qAboutData.addAuthor( "Jan Holesovsky", I18N_NOOP("Original author"), "kendy@collabora.com" ); - - // Let the user see that this does something... - ::std::cerr << "kdefilepicker, an implementation of a " THIS_DESKENV_NAME_CAP " file dialog for OOo." << ::std::endl - << "Type 'exit' and press Enter to finish." << ::std::endl; - - KCmdLineArgs::addCmdLineOptions( sOptions ); - KCmdLineArgs::init( argc, argv, &qAboutData ); - - KLocale::setMainCatalogue( "kdialog" ); - - KApplication kApplication; - - // Setup the modality - KCmdLineArgs *pArgs = KCmdLineArgs::parsedArgs(); - long nWinId = atol( pArgs->getOption( "winid" ) ); - pArgs->clear(); - - KDEModalityFilter qModalityFilter( nWinId ); - - KDEFileDialog aFileDialog( nullptr, QString(), nullptr, THIS_DESKENV_NAME_LOW "filedialog" ); - - KDECommandThread qCommandThread( &aFileDialog ); - qCommandThread.start(); - - kApplication.exec(); - - qCommandThread.wait(); - - ::std::cout << "exited" << ::std::endl; - - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/kde/fpicker/kdemodalityfilter.cxx b/vcl/unx/kde/fpicker/kdemodalityfilter.cxx deleted file mode 100644 index 007369353f54..000000000000 --- a/vcl/unx/kde/fpicker/kdemodalityfilter.cxx +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <cstddef> - -#include <kdemodalityfilter.hxx> -#include <kdialogbase.h> - -#if ENABLE_TDE -# include <tdeapplication.h> -#else // ENABLE_TDE -# include <kapplication.h> -#endif // ENABLE_TDE - -#include <netwm.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> - -// Modality filter - -KDEModalityFilter::KDEModalityFilter( WId nWinId ) - : m_nWinId( nWinId ) -{ - kapp->installEventFilter( this ); -} - -KDEModalityFilter::~KDEModalityFilter() -{ - kapp->removeEventFilter( this ); -} - -bool KDEModalityFilter::eventFilter( QObject *pObject, QEvent *pEvent ) -{ - if ( pObject->isWidgetType() && pEvent->type() == QEvent::Show ) - { - KDialogBase* pDlg = ::qt_cast< KDialogBase* >( pObject ); - if ( pDlg != nullptr && m_nWinId != 0 ) - { - XSetTransientForHint( qt_xdisplay(), pDlg->winId(), m_nWinId ); - m_nWinId = 0; - } - } - return false; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/kde/fpicker/kdemodalityfilter.hxx b/vcl/unx/kde/fpicker/kdemodalityfilter.hxx deleted file mode 100644 index 4f068e3dea43..000000000000 --- a/vcl/unx/kde/fpicker/kdemodalityfilter.hxx +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_VCL_UNX_KDE_FPICKER_KDEMODALITYFILTER_HXX -#define INCLUDED_VCL_UNX_KDE_FPICKER_KDEMODALITYFILTER_HXX - -#include <sal/config.h> - -#include <config_vclplug.h> -#include <sal/types.h> - -#if ENABLE_TDE -#include <shell/tde_defines.h> -#endif // ENABLE_TDE - -#if ENABLE_TDE -#include <tqobject.h> -#else // ENABLE_TDE -#include <qobject.h> -#endif // ENABLE_TDE - -class KDEModalityFilter : public QObject -{ -private: - WId m_nWinId; - -public: - KDEModalityFilter( WId nWinId ); - virtual ~KDEModalityFilter() override; - - virtual bool eventFilter( QObject *pObject, QEvent *pEvent ) override; -}; - -#endif // INCLUDED_VCL_UNX_KDE_FPICKER_KDEMODALITYFILTER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/kde/kdedata.cxx b/vcl/unx/kde/kdedata.cxx deleted file mode 100644 index 71955f5a764c..000000000000 --- a/vcl/unx/kde/kdedata.cxx +++ /dev/null @@ -1,238 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <shell/kde_headers.h> - -#include <unistd.h> -#include <fcntl.h> - -#include <string.h> -#include <stdlib.h> -#include <limits.h> -#include <errno.h> -#include <poll.h> -#ifdef FREEBSD -#include <sys/types.h> -#include <sys/time.h> -#endif - -#include <osl/thread.h> -#include <osl/process.h> -#include <osl/mutex.hxx> - -#include "unx/kde/kdedata.hxx" -#include "unx/i18n_im.hxx" -#include "unx/i18n_xkb.hxx" - -#include "vclpluginapi.h" - -#include <config_vclplug.h> - -/* #i59042# override KApplications method for session management - * since it will interfere badly with our own. - */ -class VCLKDEApplication : public KApplication -{ - public: - VCLKDEApplication() : KApplication() {} - - virtual void commitData(QSessionManager &sm) override; -}; - -void VCLKDEApplication::commitData(QSessionManager&) -{ -} - -/*************************************************************************** - * class SalKDEDisplay * - ***************************************************************************/ - -SalKDEDisplay::SalKDEDisplay( Display* pDisp ) - : SalX11Display( pDisp ) -{ -} - -SalKDEDisplay::~SalKDEDisplay() -{ - // in case never a frame opened - static_cast<KDEXLib*>(GetXLib())->doStartup(); - // clean up own members - doDestruct(); - // prevent SalDisplay from closing KApplication's display - pDisp_ = nullptr; -} - -/*************************************************************************** - * class KDEXLib * - ***************************************************************************/ - -KDEXLib::~KDEXLib() -{ - // on 64 bit linux using libXRandr.so.2 will crash in - // XCloseDisplay when freeing extension data - // no known work around, therefore currently leak. Hopefully - // this does not make problems since we're shutting down anyway - // should we ever get a real kde plugin that uses the KDE event loop - // we should use kde's method to signal screen changes similar - // to the gtk plugin - #if ! defined USE_RANDR || ! (defined LINUX && defined X86_64) - // properly deinitialize KApplication - delete static_cast<VCLKDEApplication*>(m_pApplication); - #endif - // free the faked cmdline arguments no longer needed by KApplication - for( int i = 0; i < m_nFakeCmdLineArgs; i++ ) - free( m_pFreeCmdLineArgs[i] ); - delete [] m_pFreeCmdLineArgs; - delete [] m_pAppCmdLineArgs; -} - -void KDEXLib::Init() -{ - m_pInputMethod = new SalI18N_InputMethod; - m_pInputMethod->SetLocale(); - XrmInitialize(); - - KAboutData *kAboutData = new KAboutData( "LibreOffice", - I18N_NOOP( "LibreOffice" ), - "3.4.0", - I18N_NOOP( "LibreOffice with KDE Native Widget Support." ), - KAboutData::License_File, - I18N_NOOP( "Copyright (C) 2000, 2014 LibreOffice contributors" ), - I18N_NOOP( "LibreOffice is an office suite.\n" ), - "http://libreoffice.org", - "libreoffice@lists.freedesktop.org"); - kAboutData->addAuthor( "Jan Holesovsky", - I18N_NOOP( "Original author and maintainer of the KDE NWF." ), - "kendy@artax.karlin.mff.cuni.cz", - "http://artax.karlin.mff.cuni.cz/~kendy" ); - - m_nFakeCmdLineArgs = 1; - sal_uInt16 nIdx; - int nParams = osl_getCommandArgCount(); - OString aDisplay; - OUString aParam, aBin; - - for ( nIdx = 0; nIdx < nParams; ++nIdx ) - { - osl_getCommandArg( nIdx, &aParam.pData ); - if ( !m_pFreeCmdLineArgs && aParam == "-display" && nIdx + 1 < nParams ) - { - osl_getCommandArg( nIdx + 1, &aParam.pData ); - aDisplay = OUStringToOString( aParam, osl_getThreadTextEncoding() ); - - m_nFakeCmdLineArgs = 3; - m_pFreeCmdLineArgs = new char*[ m_nFakeCmdLineArgs ]; - m_pFreeCmdLineArgs[ 1 ] = strdup( "-display" ); - m_pFreeCmdLineArgs[ 2 ] = strdup( aDisplay.getStr() ); - } - } - if ( !m_pFreeCmdLineArgs ) - m_pFreeCmdLineArgs = new char*[ m_nFakeCmdLineArgs ]; - - osl_getExecutableFile( &aParam.pData ); - osl_getSystemPathFromFileURL( aParam.pData, &aBin.pData ); - OString aExec = OUStringToOString( aBin, osl_getThreadTextEncoding() ); - m_pFreeCmdLineArgs[0] = strdup( aExec.getStr() ); - - // make a copy of the string list for freeing it since - // KApplication manipulates the pointers inside the argument vector - // note: KApplication bad ! - m_pAppCmdLineArgs = new char*[ m_nFakeCmdLineArgs ]; - for( int i = 0; i < m_nFakeCmdLineArgs; i++ ) - m_pAppCmdLineArgs[i] = m_pFreeCmdLineArgs[i]; - - KCmdLineArgs::init( m_nFakeCmdLineArgs, m_pAppCmdLineArgs, kAboutData ); - - KApplication::disableAutoDcopRegistration(); - m_pApplication = new VCLKDEApplication(); - kapp->disableSessionManagement(); - - m_pDisplay = QPaintDevice::x11AppDisplay(); -} - -void KDEXLib::doStartup() -{ - if( ! m_bStartupDone ) - { - KStartupInfo::appStarted(); - m_bStartupDone = true; - SAL_INFO( "vcl.kde", "called KStartupInfo::appStarted()" ); - } -} - -/********************************************************************** - * class KDEData * - **********************************************************************/ - -KDEData::~KDEData() -{ -} - -void KDEData::Init() -{ - pXLib_ = new KDEXLib(); - pXLib_->Init(); -} - -/********************************************************************** - * plugin entry point * - **********************************************************************/ - -extern "C" { - VCLPLUG_KDE_PUBLIC SalInstance* create_SalInstance() - { - /* #i92121# workaround deadlocks in the X11 implementation - */ - static const char* pNoXInitThreads = getenv( "SAL_NO_XINITTHREADS" ); - /* #i90094# - from now on we know that an X connection will be - established, so protect X against itself - */ - if( ! ( pNoXInitThreads && *pNoXInitThreads ) ) - XInitThreads(); - - OString aVersion( qVersion() ); - SAL_INFO( "vcl.kde", "qt version string is \"" << aVersion << "\"" ); - - sal_Int32 nIndex = 0, nMajor = 0, nMinor = 0, nMicro = 0; - nMajor = aVersion.getToken( 0, '.', nIndex ).toInt32(); - if( nIndex > 0 ) - nMinor = aVersion.getToken( 0, '.', nIndex ).toInt32(); - if( nIndex > 0 ) - nMicro = aVersion.getToken( 0, '.', nIndex ).toInt32(); - if( nMajor != 3 || nMinor < 2 || (nMinor == 2 && nMicro < 2) ) - { - SAL_INFO( "vcl.kde", "unsuitable qt version " << nMajor << "." << nMinor << "." << nMicro ); - return nullptr; - } - - KDESalInstance* pInstance = new KDESalInstance( new SalYieldMutex() ); - SAL_INFO( "vcl.kde", "created KDESalInstance " << &pInstance ); - - // initialize SalData - KDEData *pSalData = new KDEData( pInstance ); - pSalData->Init(); - pInstance->SetLib( pSalData->GetLib() ); - pSalData->initNWF(); - - return pInstance; - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/kde/salnativewidgets-kde.cxx b/vcl/unx/kde/salnativewidgets-kde.cxx deleted file mode 100644 index d829edaf70b3..000000000000 --- a/vcl/unx/kde/salnativewidgets-kde.cxx +++ /dev/null @@ -1,2097 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <shell/kde_headers.h> - -#include "UnxFilePicker.hxx" - -#include <unx/salunx.h> -#include <unx/saldata.hxx> -#include <unx/saldisp.hxx> -#include <unx/salgdi.h> -#include <unx/kde/kdedata.hxx> -#include "unx/pixmap.hxx" -#include <unx/i18n_im.hxx> - -#include <vcl/settings.hxx> -#include "unx/fontmanager.hxx" -#include <vcl/vclenum.hxx> -#include <rtl/ustrbuf.hxx> - -#include <config_vclplug.h> - -#include <boost/optional.hpp> - -#if ENABLE_TDE -#define QPushButton_String "TQPushButton" -#define QRadioButton_String "TQRadioButton" -#define QCheckBox_String "TQCheckBox" -#define QComboBox_String "TQComboBox" -#define QLineEdit_String "TQLineEdit" -#define QSpinWidget_String "TQSpinWidget" -#define QTabBar_String "TQTabBar" -#define QTabWidget_String "TQTabWidget" -#define QListView_String "TQListView" -#define QScrollBar_String "TQScrollBar" -#define QMotifPlusStyle_String "TQMotifPlusStyle" -#define QSGIStyle_String "TQSGIStyle" -#define QToolBar_String "TQToolBar" -#define QToolButton_String "TQToolButton" -#define QMenuBar_String "TQMenuBar" -#define QPopupMenu_String "TQPopupMenu" -#define QProgressBar_String "TQProgressBar" -#define QMotifStyle_String "TQMotifStyle" -#define QWindowsStyle_String "TQWindowsStyle" -#else // ENABLE_TDE -#define QPushButton_String "QPushButton" -#define QRadioButton_String "QRadioButton" -#define QCheckBox_String "QCheckBox" -#define QComboBox_String "QComboBox" -#define QLineEdit_String "QLineEdit" -#define QSpinWidget_String "QSpinWidget" -#define QTabBar_String "QTabBar" -#define QTabWidget_String "QTabWidget" -#define QListView_String "QListView" -#define QScrollBar_String "QScrollBar" -#define QMotifPlusStyle_String "QMotifPlusStyle" -#define QSGIStyle_String "QSGIStyle" -#define QToolBar_String "QToolBar" -#define QToolButton_String "QToolButton" -#define QMenuBar_String "QMenuBar" -#define QPopupMenu_String "QPopupMenu" -#define QProgressBar_String "QProgressBar" -#define QMotifStyle_String "QMotifStyle" -#define QWindowsStyle_String "QWindowsStyle" -#endif // ENABLE_TDE - -using namespace ::com::sun::star; - -namespace { - -/** Style conversion function. - - Conversion function between VCL ControlState together with ImplControlValue - and Qt state flags. - - @param nState - State of the widget (default, focused, ...) as defined in Native Widget - Framework. - - @param aValue - Value held by the widget (on, off, ...) -*/ -QStyle::SFlags vclStateValue2SFlags( ControlState nState, - const ImplControlValue& aValue ) -{ - QStyle::SFlags nStyle = - ( (nState & ControlState::DEFAULT)? QStyle::Style_ButtonDefault: QStyle::Style_Default ) | - ( (nState & ControlState::ENABLED)? QStyle::Style_Enabled: QStyle::Style_Default ) | - ( (nState & ControlState::FOCUSED)? QStyle::Style_HasFocus: QStyle::Style_Default ) | - ( (nState & ControlState::PRESSED)? QStyle::Style_Down: QStyle::Style_Raised ) | - ( (nState & ControlState::SELECTED)? QStyle::Style_Selected : QStyle::Style_Default ) | - ( (nState & ControlState::ROLLOVER)? QStyle::Style_MouseOver: QStyle::Style_Default ); - - switch ( aValue.getTristateVal() ) - { - case ButtonValue::On: nStyle |= QStyle::Style_On; break; - case ButtonValue::Off: nStyle |= QStyle::Style_Off; break; - case ButtonValue::Mixed: nStyle |= QStyle::Style_NoChange; break; - default: break; - } - - return nStyle; -} - -} - -/** Qt implementation of X11Pixmap - - Wrapper around a QPixmap. - */ - -class KDEX11Pixmap : public X11Pixmap -{ -public: - KDEX11Pixmap( int nWidth, int nHeight ); - - virtual int GetDepth() const override; - virtual SalX11Screen GetScreen() const override; - virtual Pixmap GetPixmap() const override; - QPixmap GetQPixmap() const; - -protected: - QPixmap mqPixmap; -}; - -KDEX11Pixmap::KDEX11Pixmap( int nWidth, int nHeight ) -: X11Pixmap( nWidth, nHeight ) -, mqPixmap( nWidth, nHeight ) -{ -} - -int KDEX11Pixmap::GetDepth() const -{ - return mqPixmap.x11Depth(); -} - -SalX11Screen KDEX11Pixmap::GetScreen() const -{ - return SalX11Screen( mqPixmap.x11Screen() ); -} - -Pixmap KDEX11Pixmap::GetPixmap() const -{ - return mqPixmap.handle(); -} - -QPixmap KDEX11Pixmap::GetQPixmap() const -{ - return mqPixmap; -} - - -/** Cached native widgets. - - A class which caches and paints the native widgets. -*/ -class WidgetPainter -{ - protected: - /** Cached push button. - - It is necessary for the QStyle::drawControl(). The buttons are created - on demand and they are still hidden (no QWidget::show() is called). - */ - QPushButton *m_pPushButton; - - /** Cached radio button. - - @see m_pPushButton - */ - QRadioButton *m_pRadioButton; - - /** Cached check box. - - @see m_pPushButton - */ - QCheckBox *m_pCheckBox; - - /** Cached combo box. - - @see m_pPushButton - */ - QComboBox *m_pComboBox; - - /** Cached editable combo box. - - Needed, because some styles do not like dynamic changes - (QComboBox::setEditable()). - - @see m_pPushButton - */ - QComboBox *m_pEditableComboBox; - - /** Cached line edit box. - - @see m_pPushButton - */ - QLineEdit *m_pLineEdit; - - /** Cached spin box. - - @see m_pPushButton - */ - QSpinWidget *m_pSpinWidget; - - /** Cached spin box'es line edit. - - @see m_pPushButton - */ - QLineEdit *m_pSpinEdit; - - /** Cached tab. - - Left, middle, right tab and a tab which is alone. - - @see m_pPushButton - */ - QTab *m_pTabLeft, *m_pTabMiddle, *m_pTabRight, *m_pTabAlone; - - /** Cached tab bar's parent widget. - - Needed, because the Qt windows style checks for the availability - of tab bar's parent. We cannot use m_pTabWidget, because - TabWidget::setTabBar() and TabWidget::tabBar() methods are - protected. - - @see m_pPushButton, m_pTabWidget - */ - QWidget *m_pTabBarParent; - - /** Cached tab bar widget. - - @see m_pPushButton - */ - QTabBar *m_pTabBar; - - /** Cached tab widget. - - We need it to draw the tab page. It cannot be used to draw the - tabs themselves, because the drawing has to be tweaked a little - due to not enough information from VCL. - - @see m_pPushButton, m_pTabBarParent - */ - QTabWidget *m_pTabWidget; - - /** Cached list view. - - @see m_pPushButton - */ - QListView *m_pListView; - - /** Cached scroll bar. - - @see m_pPushButton - */ - QScrollBar *m_pScrollBar; - - /** Cached dock area. Needed for proper functionality of tool bars. - - @see m_pPushButton - */ - QMainWindow *m_pMainWindow; - - /** Cached tool bar. - - @see m_pPushButton - */ - QToolBar *m_pToolBarHoriz, *m_pToolBarVert; - - /** Cached tool button. - - @see m_pPushButton - */ - QToolButton *m_pToolButton; - - /** Cached menu bar. - - @see m_pPushButton - */ - QMenuBar *m_pMenuBar; - - /** Identifiers of menu bar items. - */ - int m_nMenuBarEnabledItem, m_nMenuBarDisabledItem; - - /** Cached popup menu. - - @see m_pPushButton - */ - QPopupMenu *m_pPopupMenu; - - /** Identifiers of popup menu items. - */ - int m_nPopupMenuEnabledItem, m_nPopupMenuDisabledItem; - - /** cached progress bar - */ - QProgressBar *m_pProgressBar; - - // TODO other widgets - - public: - /** Implicit constructor. - - It creates an empty WidgetPainter with all the cached widgets initialized - to nullptr. The widgets are created on demand and they are still hidden - (no QWidget::show()), because they are needed just as a parameter for - QStyle::drawControl(). - - @see m_pPushButton - */ - WidgetPainter(); - - /** Destructor. - - Destruct all the cached widgets. - */ - virtual ~WidgetPainter(); - - /** Paints the specified widget to the X window. - - Use X calls to bitblt (bit block transfer) the widget qWidget to - the window specified by drawable with the style defined by nStyle. - - @param qWidget - A pointer to the cached widget. - - @param nState - The state of the control (focused, on/off, ...) - - @param aValue - The value (true/false, ...) - - @param pGraphics - The SalGraphics instance to read/write screen. - */ - bool drawStyledWidget( QWidget *pWidget, - ControlState nState, const ImplControlValue& aValue, - X11SalGraphics* pGraphics, - ControlPart nPart = ControlPart::Entire ); - - /** 'Get' method for push button. - - The method returns the cached push button. It is constructed if it - does not exist. It has nullptr as a parent and it stays hidden, but it - is necessary for the drawStyledWidget() method. - - @return valid push button. - */ - QPushButton *pushButton( const tools::Rectangle& rControlRegion, bool bDefault ); - - /** 'Get' method for radio button. - - @see pushButton() - */ - QRadioButton *radioButton( const tools::Rectangle& rControlRegion ); - - /** 'Get' method for check box. - - @see pushButton() - */ - QCheckBox *checkBox( const tools::Rectangle& rControlRegion ); - - /** 'Get' method for combo box. - - It returns m_pComboBox or m_pEditableComboBox according to - bEditable. - - @see pushButton(), m_pEditableComboBox - */ - QComboBox *comboBox( const tools::Rectangle& rControlRegion, bool bEditable ); - - /** 'Get' method for line edit box. - - @see pushButton() - */ - QLineEdit *lineEdit( const tools::Rectangle& rControlRegion ); - - /** 'Get' method for spin box. - - @see pushButton() - */ - QSpinWidget *spinWidget( const tools::Rectangle& rControlRegion ); - - /** 'Get' method for tab bar. - - @see pushButton() - */ - QTabBar *tabBar( const tools::Rectangle& rControlRegion ); - - /** 'Get' method for tab widget. - - @see pushButton() - */ - QTabWidget *tabWidget( const tools::Rectangle& rControlRegion ); - - /** 'Get' method for list view. - - @see pushButton() - */ - QListView *listView( const tools::Rectangle& rControlRegion ); - - /** 'Get' method for scroll bar. - - @see pushButton() - */ - QScrollBar *scrollBar( const tools::Rectangle& rControlRegion, - bool bHorizontal, const ImplControlValue& aValue ); - - /** 'Get' method for tool bar. - - @see pushButton() - */ - QToolBar *toolBar( const tools::Rectangle& rControlRegion, bool bHorizontal ); - - /** 'Get' method for tool button. - - @see pushButton() - */ - QToolButton *toolButton( const tools::Rectangle& rControlRegion ); - - /** 'Get' method for menu bar. - - @see pushButton() - */ - QMenuBar *menuBar( const tools::Rectangle& rControlRegion ); - - /** 'Get' method for popup menu. - - @see pushButton() - */ - QPopupMenu *popupMenu( const tools::Rectangle& rControlRegion ); - - /** 'Get' method for progress bar - - @see pushButton() - */ - QProgressBar *progressBar( const tools::Rectangle& rControlRegion ); - - // TODO other widgets - - public: - /** Convert tools::Rectangle to QRect. - - @param rControlRegion - The region to convert. - - @return - The bounding box of the region. - */ - static QRect region2QRect( const tools::Rectangle& rControlRegion ); -}; - -WidgetPainter::WidgetPainter() - : m_pPushButton( nullptr ), - m_pRadioButton( nullptr ), - m_pCheckBox( nullptr ), - m_pComboBox( nullptr ), - m_pEditableComboBox( nullptr ), - m_pLineEdit( nullptr ), - m_pSpinWidget( nullptr ), - m_pSpinEdit( nullptr ), - m_pTabLeft( nullptr ), - m_pTabMiddle( nullptr ), - m_pTabRight( nullptr ), - m_pTabAlone( nullptr ), - m_pTabBarParent( nullptr ), - m_pTabBar( nullptr ), - m_pTabWidget( nullptr ), - m_pListView( nullptr ), - m_pScrollBar( nullptr ), - m_pMainWindow( nullptr ), - m_pToolBarHoriz( nullptr ), - m_pToolBarVert( nullptr ), - m_pToolButton( nullptr ), - m_pMenuBar( nullptr ), - m_nMenuBarEnabledItem( 0 ), - m_nMenuBarDisabledItem( 0 ), - m_pPopupMenu( nullptr ), - m_nPopupMenuEnabledItem( 0 ), - m_nPopupMenuDisabledItem( 0 ), - m_pProgressBar( nullptr ) -{ -} - -WidgetPainter::~WidgetPainter() -{ - delete m_pPushButton; m_pPushButton = nullptr; - delete m_pRadioButton; m_pRadioButton = nullptr; - delete m_pCheckBox; m_pCheckBox = nullptr; - delete m_pComboBox; m_pComboBox = nullptr; - delete m_pEditableComboBox; m_pEditableComboBox = nullptr; - delete m_pLineEdit; m_pLineEdit = nullptr; - delete m_pSpinWidget; m_pSpinWidget = nullptr; - m_pSpinEdit = nullptr; // Deleted in m_pSpinWidget's destructor - delete m_pTabAlone; m_pTabAlone = nullptr; - delete m_pTabBarParent; m_pTabBarParent = nullptr; - m_pTabBar = nullptr; // Deleted in m_pTabBarParent's destructor - m_pTabLeft = nullptr; - m_pTabMiddle = nullptr; - m_pTabRight = nullptr; - delete m_pTabWidget; m_pTabWidget = nullptr; - delete m_pListView; m_pListView = nullptr; - delete m_pScrollBar; m_pScrollBar = nullptr; - delete m_pToolBarHoriz; m_pToolBarHoriz = nullptr; - delete m_pToolBarVert; m_pToolBarVert = nullptr; - delete m_pMainWindow; m_pMainWindow = nullptr; - delete m_pToolButton; m_pToolButton = nullptr; - delete m_pMenuBar; m_pMenuBar = nullptr; - delete m_pPopupMenu; m_pPopupMenu = nullptr; - delete m_pProgressBar; m_pProgressBar = nullptr; -} - -bool WidgetPainter::drawStyledWidget( QWidget *pWidget, - ControlState nState, const ImplControlValue& aValue, - X11SalGraphics* pGraphics, ControlPart nPart ) -{ - if ( !pWidget ) - return false; - - // Normalize the widget - QPoint qWidgetPos( pWidget->pos() ); - pWidget->move( 0, 0 ); - - // Enable/disable the widget - pWidget->setEnabled( bool(nState & ControlState::ENABLED) ); - - // Create pixmap to paint to - KDEX11Pixmap xPixmap( pWidget->width(), pWidget->height() ); - QPixmap qPixmap( xPixmap.GetQPixmap() ); - QPainter qPainter( &qPixmap ); - QRect qRect( 0, 0, pWidget->width(), pWidget->height() ); - - // Use the background of the widget - qPixmap.fill( pWidget, QPoint(0, 0) ); - - // Convert the flags - QStyle::SFlags nStyle = vclStateValue2SFlags( nState, aValue ); - - // Store the widget class - const char *pClassName = pWidget->className(); - - // Draw the widget to the pixmap - if ( strcmp( QPushButton_String, pClassName ) == 0 ) - { - // Workaround for the Platinum style. - // Platinum takes the state directly from the widget, not from SFlags. - QPushButton *pPushButton = static_cast<QPushButton *>( pWidget->qt_cast( QPushButton_String ) ); - if ( pPushButton ) - { - pPushButton->setDown ( nStyle & QStyle::Style_Down ); - pPushButton->setOn ( nStyle & QStyle::Style_On ); - pPushButton->setEnabled( nStyle & QStyle::Style_Enabled ); - } - - QApplication::style().drawControl( QStyle::CE_PushButton, - &qPainter, pWidget, qRect, - pWidget->colorGroup(), nStyle ); - } - else if ( strcmp( QRadioButton_String, pClassName ) == 0 ) - { - // Bitblt from the screen, because the radio buttons are usually not - // rectangular, and there could be a bitmap under them - pGraphics->FillPixmapFromScreen( &xPixmap, qWidgetPos.x(), qWidgetPos.y() ); - - QApplication::style().drawControl( QStyle::CE_RadioButton, - &qPainter, pWidget, qRect, - pWidget->colorGroup(), nStyle ); - } - else if ( strcmp( QCheckBox_String, pClassName ) == 0 ) - { - QApplication::style().drawControl( QStyle::CE_CheckBox, - &qPainter, pWidget, qRect, - pWidget->colorGroup(), nStyle ); - } - else if ( strcmp( QComboBox_String, pClassName ) == 0 ) - { - QApplication::style().drawComplexControl( QStyle::CC_ComboBox, - &qPainter, pWidget, qRect, - pWidget->colorGroup(), nStyle ); - - // Editable combo box uses the background of the associated edit box - QComboBox *pComboBox = static_cast<QComboBox *>( pWidget->qt_cast( QComboBox_String ) ); - if ( pComboBox && pComboBox->editable() && pComboBox->lineEdit() ) - { - QColorGroup::ColorRole eColorRole = ( pComboBox->isEnabled() )? - QColorGroup::Base: QColorGroup::Background; - qPainter.fillRect( - QApplication::style().querySubControlMetrics( QStyle::CC_ComboBox, - pComboBox, QStyle::SC_ComboBoxEditField ), - pComboBox->lineEdit()->colorGroup().brush( eColorRole ) ); - } - } - else if ( strcmp( QLineEdit_String, pClassName ) == 0 ) - { - QApplication::style().drawPrimitive( QStyle::PE_PanelLineEdit, - &qPainter, qRect, - pWidget->colorGroup(), nStyle | QStyle::Style_Sunken ); - } - else if ( strcmp( QSpinWidget_String, pClassName ) == 0 ) - { - const SpinbuttonValue* pValue = (aValue.getType() == ControlType::SpinButtons) ? static_cast<const SpinbuttonValue*>(&aValue) : nullptr; - - // Is any of the buttons pressed? - QStyle::SCFlags eActive = QStyle::SC_None; - if ( pValue ) - { - if ( pValue->mnUpperState & ControlState::PRESSED ) - eActive = QStyle::SC_SpinWidgetUp; - else if ( pValue->mnLowerState & ControlState::PRESSED ) - eActive = QStyle::SC_SpinWidgetDown; - - // Update the enable/disable state of the widget - if ( ( nState & ControlState::ENABLED ) || - ( pValue->mnUpperState & ControlState::ENABLED ) || - ( pValue->mnLowerState & ControlState::ENABLED ) ) - { - pWidget->setEnabled( true ); - nStyle |= QStyle::Style_Enabled; - } - else - pWidget->setEnabled( false ); - - // Mouse-over effect - if ( (pValue->mnUpperState & ControlState::ROLLOVER) || - (pValue->mnLowerState & ControlState::ROLLOVER) ) - nStyle |= QStyle::Style_MouseOver; - } - - // Spin widget uses the background of the associated edit box - QSpinWidget *pSpinWidget = static_cast<QSpinWidget *>( pWidget->qt_cast( QSpinWidget_String ) ); - if ( pSpinWidget && pSpinWidget->editWidget() ) - { - QColorGroup::ColorRole eColorRole = ( pSpinWidget->isEnabled() )? - QColorGroup::Base: QColorGroup::Background; - qPainter.fillRect( - QApplication::style().querySubControlMetrics( QStyle::CC_SpinWidget, - pSpinWidget, QStyle::SC_SpinWidgetEditField ), - pSpinWidget->editWidget()->colorGroup().brush( eColorRole ) ); - } - - // Adjust the frame (needed for Motif Plus style) - QRect qFrameRect = QApplication::style().querySubControlMetrics( QStyle::CC_SpinWidget, - pWidget, QStyle::SC_SpinWidgetFrame ); - - QApplication::style().drawComplexControl( QStyle::CC_SpinWidget, - &qPainter, pWidget, qFrameRect, - pWidget->colorGroup(), nStyle, - QStyle::SC_All, eActive ); - } - else if ( strcmp( QTabBar_String, pClassName ) == 0 ) - { - const TabitemValue *pValue = static_cast<const TabitemValue *> ( &aValue ); - - QTab *pTab = nullptr; - if ( pValue ) - { - if ( ( pValue->isFirst() || pValue->isLeftAligned() ) && ( pValue->isLast() || pValue->isRightAligned() ) ) - pTab = m_pTabAlone; - else if ( pValue->isFirst() || pValue->isLeftAligned() ) - pTab = m_pTabLeft; - else if ( pValue->isLast() || pValue->isRightAligned() ) - pTab = m_pTabRight; - else - pTab = m_pTabMiddle; - } - if ( !pTab ) - return false; - - pTab->setRect( qRect ); - - QApplication::style().drawControl( QStyle::CE_TabBarTab, - &qPainter, pWidget, qRect, - pWidget->colorGroup(), nStyle, - QStyleOption( pTab ) ); - } - else if ( strcmp( QTabWidget_String, pClassName ) == 0 ) - { - QApplication::style().drawPrimitive( QStyle::PE_PanelTabWidget, - &qPainter, qRect, - pWidget->colorGroup(), nStyle ); - } - else if ( strcmp( QListView_String, pClassName ) == 0 ) - { - QApplication::style().drawPrimitive( QStyle::PE_Panel, - &qPainter, qRect, - pWidget->colorGroup(), nStyle | QStyle::Style_Sunken ); - } - else if ( strcmp( QScrollBar_String, pClassName ) == 0 ) - { - const ScrollbarValue* pValue = (aValue.getType() == ControlType::Scrollbar) ? static_cast<const ScrollbarValue*>(&aValue) : nullptr; - - QStyle::SCFlags eActive = QStyle::SC_None; - if ( pValue ) - { - // Workaround for Style_MouseOver-aware themes. - // Quite ugly, but I do not know about a better solution. - const char *pStyleName = QApplication::style().className(); - if ( strcmp( QMotifPlusStyle_String, pStyleName ) == 0 ) - { - nStyle |= QStyle::Style_MouseOver; - if ( pValue->mnThumbState & ControlState::ROLLOVER ) - eActive = QStyle::SC_ScrollBarSlider; - } - else if ( strcmp( QSGIStyle_String, pStyleName ) == 0 ) - { - nStyle |= QStyle::Style_MouseOver; - if ( pValue->mnButton1State & ControlState::ROLLOVER ) - eActive = QStyle::SC_ScrollBarSubLine; - else if ( pValue->mnButton2State & ControlState::ROLLOVER ) - eActive = QStyle::SC_ScrollBarAddLine; - else if ( pValue->mnThumbState & ControlState::ROLLOVER ) - eActive = QStyle::SC_ScrollBarSlider; - } - - if ( pValue->mnButton1State & ControlState::PRESSED ) - eActive = QStyle::SC_ScrollBarSubLine; - else if ( pValue->mnButton2State & ControlState::PRESSED ) - eActive = QStyle::SC_ScrollBarAddLine; - else if ( pValue->mnThumbState & ControlState::PRESSED ) - eActive = QStyle::SC_ScrollBarSlider; - else if ( pValue->mnPage1State & ControlState::PRESSED ) - eActive = QStyle::SC_ScrollBarSubPage; - else if ( pValue->mnPage2State & ControlState::PRESSED ) - eActive = QStyle::SC_ScrollBarAddPage; - - // Update the enable/disable state of the widget - if ( ( nState & ControlState::ENABLED ) || - ( pValue->mnButton1State & ControlState::ENABLED ) || - ( pValue->mnButton2State & ControlState::ENABLED ) || - ( pValue->mnThumbState & ControlState::ENABLED ) || - ( pValue->mnPage1State & ControlState::ENABLED ) || - ( pValue->mnPage2State & ControlState::ENABLED ) ) - { - pWidget->setEnabled( true ); - nStyle |= QStyle::Style_Enabled; - } - else - pWidget->setEnabled( false ); - } - - // Is it a horizontal scroll bar? - QScrollBar *pScrollBar = static_cast<QScrollBar *> ( pWidget->qt_cast( QScrollBar_String ) ); - QStyle::StyleFlags eHoriz = QStyle::Style_Default; - if ( pScrollBar && pScrollBar->orientation() == Qt::Horizontal ) - eHoriz = QStyle::Style_Horizontal; - - QApplication::style().drawComplexControl( QStyle::CC_ScrollBar, - &qPainter, pWidget, qRect, - pWidget->colorGroup(), nStyle | eHoriz, - QStyle::SC_All, eActive ); - } - else if ( strcmp( QToolBar_String, pClassName ) == 0 ) - { - QToolBar *pToolBar = static_cast< QToolBar * >( pWidget->qt_cast( QToolBar_String ) ); - bool bIsHorizontal = false; - if ( pToolBar && pToolBar->orientation() == Qt::Horizontal ) - { - nStyle |= QStyle::Style_Horizontal; - bIsHorizontal = true; - } - - QApplication::style().drawControl( QStyle::CE_DockWindowEmptyArea, - &qPainter, pWidget, qRect, - pWidget->colorGroup(), nStyle ); - - QApplication::style().drawPrimitive( QStyle::PE_PanelDockWindow, - &qPainter, qRect, pWidget->colorGroup(), nStyle ); - - if ( nPart == ControlPart::ThumbHorz || nPart == ControlPart::ThumbVert ) - { - const ToolbarValue *pValue = static_cast< const ToolbarValue * >( &aValue ); - - QRect qThumbRect = region2QRect( pValue->maGripRect ); - qThumbRect.moveBy( -qWidgetPos.x(), -qWidgetPos.y() ); - if ( bIsHorizontal ) - qThumbRect.addCoords( 0, 2, 0, -3 ); // make the thumb a bit nicer - else - qThumbRect.addCoords( 2, 0, -3, 0 ); // make the thumb a bit nicer - - if ( QApplication::style().inherits( "HighColorStyle" ) || - QApplication::style().inherits( "HighContrastStyle" ) || - QApplication::style().inherits( "KeramikStyle" ) || - QApplication::style().inherits( "KThemeStyle" ) || - QApplication::style().inherits( "ThinKeramikStyle" ) ) - { - // Workaround for the workaround in KStyle::drawPrimitive() - KStyle *pStyle = static_cast< KStyle * >( &QApplication::style() ); - pStyle->drawKStylePrimitive( KStyle::KPE_ToolBarHandle, - &qPainter, pToolBar, qThumbRect, - pWidget->colorGroup(), nStyle ); - } - else - QApplication::style().drawPrimitive( QStyle::PE_DockWindowHandle, - &qPainter, qThumbRect, pWidget->colorGroup(), nStyle ); - } - } - else if ( strcmp( QToolButton_String, pClassName ) == 0 ) - { - if( (nStyle & QStyle::Style_MouseOver) ) - nStyle &= ~QStyle::Style_Off; - QApplication::style().drawComplexControl( QStyle::CC_ToolButton, - &qPainter, pWidget, qRect, - pWidget->colorGroup(), nStyle, - QStyle::SC_ToolButton ); - } - else if ( strcmp( QMenuBar_String, pClassName ) == 0 ) - { - if ( nPart == ControlPart::Entire ) - { - QApplication::style().drawControl( QStyle::CE_MenuBarEmptyArea, - &qPainter, pWidget, qRect, - pWidget->colorGroup(), nStyle ); - } - else if ( nPart == ControlPart::MenuItem ) - { - int nMenuItem = ( nStyle & QStyle::Style_Enabled )? m_nMenuBarEnabledItem: m_nMenuBarDisabledItem; - QMenuItem *pMenuItem = static_cast<QMenuBar*>( pWidget )->findItem( nMenuItem ); - - if ( ( nStyle & QStyle::Style_MouseOver ) - && QApplication::style().styleHint( QStyle::SH_MenuBar_MouseTracking ) ) - nStyle |= QStyle::Style_Active; - - if ( nStyle & QStyle::Style_Selected ) - nStyle |= QStyle::Style_Active | QStyle::Style_Down | QStyle::Style_HasFocus; - - QApplication::style().drawControl( QStyle::CE_MenuBarItem, - &qPainter, pWidget, qRect, - pWidget->colorGroup(), nStyle, - QStyleOption( pMenuItem ) ); - } - } - else if ( strcmp( QPopupMenu_String, pClassName ) == 0 ) - { - int nMenuItem = ( nStyle & QStyle::Style_Enabled )? m_nPopupMenuEnabledItem: m_nPopupMenuDisabledItem; - QMenuItem *pMenuItem = static_cast<QPopupMenu*>( pWidget )->findItem( nMenuItem ); - - if ( nStyle & QStyle::Style_Selected ) - nStyle |= QStyle::Style_Active; - - QApplication::style().drawControl( QStyle::CE_PopupMenuItem, - &qPainter, pWidget, qRect, - pWidget->colorGroup(), nStyle, - QStyleOption( pMenuItem, 0, 0 ) ); - } - else if ( strcmp( QProgressBar_String, pClassName ) == 0 ) - { - long nProgressWidth = aValue.getNumericVal(); - QProgressBar* pProgress = static_cast<QProgressBar*>(pWidget); - pProgress->setProgress( nProgressWidth, qRect.width() ); - - QApplication::style().drawControl( QStyle::CE_ProgressBarGroove, - &qPainter, pWidget, qRect, - pWidget->colorGroup(), nStyle ); - QApplication::style().drawControl( QStyle::CE_ProgressBarContents, - &qPainter, pWidget, qRect, - pWidget->colorGroup(), nStyle ); - } - else - return false; - - // Bitblt it to the screen - pGraphics->RenderPixmapToScreen( &xPixmap, nullptr, qWidgetPos.x(), qWidgetPos.y() ); - - // Restore widget's position - pWidget->move( qWidgetPos ); - - return true; -} - -QPushButton *WidgetPainter::pushButton( const tools::Rectangle& rControlRegion, - bool bDefault ) -{ - if ( !m_pPushButton ) - m_pPushButton = new QPushButton( nullptr, "push_button" ); - - QRect qRect = region2QRect( rControlRegion ); - - // Workaround for broken styles which do not add - // QStyle::PM_ButtonDefaultIndicator to the size of the default button - // (for example Keramik) - // FIXME Fix Keramik style to be consistent with Qt built-in styles. Aargh! - if ( bDefault ) - { - QSize qContentsSize( 50, 50 ); - m_pPushButton->setDefault( false ); - QSize qNormalSize = QApplication::style().sizeFromContents( QStyle::CT_PushButton, - m_pPushButton, qContentsSize ); - m_pPushButton->setDefault( true ); - QSize qDefSize = QApplication::style().sizeFromContents( QStyle::CT_PushButton, - m_pPushButton, qContentsSize ); - - int nIndicatorSize = QApplication::style().pixelMetric( - QStyle::PM_ButtonDefaultIndicator, m_pPushButton ); - if ( qNormalSize.width() == qDefSize.width() ) - qRect.addCoords( nIndicatorSize, 0, -nIndicatorSize, 0 ); - if ( qNormalSize.height() == qDefSize.height() ) - qRect.addCoords( 0, nIndicatorSize, 0, -nIndicatorSize ); - } - - m_pPushButton->move( qRect.topLeft() ); - m_pPushButton->resize( qRect.size() ); - m_pPushButton->setDefault( bDefault ); - - return m_pPushButton; -} - -QRadioButton *WidgetPainter::radioButton( const tools::Rectangle& rControlRegion ) -{ - if ( !m_pRadioButton ) - m_pRadioButton = new QRadioButton( nullptr, "radio_button" ); - - QRect qRect = region2QRect( rControlRegion ); - - // Workaround for broken themes which do not honor the given size. - // Quite ugly, but I do not know about a better solution. - const char *pStyleName = QApplication::style().className(); - if ( strcmp( "KThemeStyle", pStyleName ) == 0 ) - { - QRect qOldRect( qRect ); - - qRect.setWidth( QApplication::style().pixelMetric( - QStyle::PM_ExclusiveIndicatorWidth, m_pRadioButton ) ); - qRect.setHeight( QApplication::style().pixelMetric( - QStyle::PM_ExclusiveIndicatorHeight, m_pRadioButton ) ); - - qRect.moveBy( ( qOldRect.width() - qRect.width() ) / 2, - ( qOldRect.height() - qRect.height() ) / 2 ); - } - - m_pRadioButton->move( qRect.topLeft() ); - m_pRadioButton->resize( qRect.size() ); - - return m_pRadioButton; -} - -QCheckBox *WidgetPainter::checkBox( const tools::Rectangle& rControlRegion ) -{ - if ( !m_pCheckBox ) - m_pCheckBox = new QCheckBox( nullptr, "check_box" ); - - QRect qRect = region2QRect( rControlRegion ); - - // Workaround for broken themes which do not honor the given size. - // Quite ugly, but I do not know about a better solution. - const char *pStyleName = QApplication::style().className(); - if ( strcmp( "KThemeStyle", pStyleName ) == 0 ) - { - QRect qOldRect( qRect ); - - qRect.setWidth( QApplication::style().pixelMetric( - QStyle::PM_IndicatorWidth, m_pCheckBox ) ); - qRect.setHeight( QApplication::style().pixelMetric( - QStyle::PM_IndicatorHeight, m_pCheckBox ) ); - - qRect.moveBy( ( qOldRect.width() - qRect.width() ) / 2, - ( qOldRect.height() - qRect.height() ) / 2 ); - } - - m_pCheckBox->move( qRect.topLeft() ); - m_pCheckBox->resize( qRect.size() ); - - return m_pCheckBox; -} - -QComboBox *WidgetPainter::comboBox( const tools::Rectangle& rControlRegion, - bool bEditable ) -{ - QComboBox *pComboBox = nullptr; - if ( bEditable ) - { - if ( !m_pEditableComboBox ) - m_pEditableComboBox = new QComboBox( true, nullptr, "combo_box_edit" ); - pComboBox = m_pEditableComboBox; - } - else - { - if ( !m_pComboBox ) - m_pComboBox = new QComboBox( false, nullptr, "combo_box" ); - pComboBox = m_pComboBox; - } - - QRect qRect = region2QRect( rControlRegion ); - - pComboBox->move( qRect.topLeft() ); - pComboBox->resize( qRect.size() ); - - return pComboBox; -} - -QLineEdit *WidgetPainter::lineEdit( const tools::Rectangle& rControlRegion ) -{ - if ( !m_pLineEdit ) - m_pLineEdit = new QLineEdit( nullptr, "line_edit" ); - - QRect qRect = region2QRect( rControlRegion ); - - m_pLineEdit->move( qRect.topLeft() ); - m_pLineEdit->resize( qRect.size() ); - - return m_pLineEdit; -} - -QSpinWidget *WidgetPainter::spinWidget( const tools::Rectangle& rControlRegion ) -{ - if ( !m_pSpinWidget ) - { - m_pSpinWidget = new QSpinWidget( nullptr, "spin_widget" ); - m_pSpinEdit = new QLineEdit( nullptr, "line_edit_spin" ); - m_pSpinWidget->setEditWidget( m_pSpinEdit ); - } - - QRect qRect = region2QRect( rControlRegion ); - - m_pSpinWidget->move( qRect.topLeft() ); - m_pSpinWidget->resize( qRect.size() ); - m_pSpinWidget->arrange(); - - return m_pSpinWidget; -} - -QTabBar *WidgetPainter::tabBar( const tools::Rectangle& rControlRegion ) -{ - if ( !m_pTabBar ) - { - if ( !m_pTabBarParent ) - m_pTabBarParent = new QWidget( nullptr, "tab_bar_parent" ); - - m_pTabBar = new QTabBar( m_pTabBarParent, "tab_bar" ); - - m_pTabLeft = new QTab(); - m_pTabMiddle = new QTab(); - m_pTabRight = new QTab(); - m_pTabAlone = new QTab(); - - m_pTabBar->addTab( m_pTabLeft ); - m_pTabBar->addTab( m_pTabMiddle ); - m_pTabBar->addTab( m_pTabRight ); - } - - QRect qRect = region2QRect( rControlRegion ); - - m_pTabBar->move( qRect.topLeft() ); - m_pTabBar->resize( qRect.size() ); - - m_pTabBar->setShape( QTabBar::RoundedAbove ); - - return m_pTabBar; -} - -QTabWidget *WidgetPainter::tabWidget( const tools::Rectangle& rControlRegion ) -{ - if ( !m_pTabWidget ) - m_pTabWidget = new QTabWidget( nullptr, "tab_widget" ); - - QRect qRect = region2QRect( rControlRegion ); - --qRect.rTop(); - - m_pTabWidget->move( qRect.topLeft() ); - m_pTabWidget->resize( qRect.size() ); - - return m_pTabWidget; -} - -QListView *WidgetPainter::listView( const tools::Rectangle& rControlRegion ) -{ - if ( !m_pListView ) - m_pListView = new QListView( nullptr, "list_view" ); - - QRect qRect = region2QRect( rControlRegion ); - - m_pListView->move( qRect.topLeft() ); - m_pListView->resize( qRect.size() ); - - return m_pListView; -} - -QScrollBar *WidgetPainter::scrollBar( const tools::Rectangle& rControlRegion, - bool bHorizontal, const ImplControlValue& aValue ) -{ - if ( !m_pScrollBar ) - { - m_pScrollBar = new QScrollBar( nullptr, "scroll_bar" ); - m_pScrollBar->setTracking( false ); - m_pScrollBar->setLineStep( 1 ); - } - - QRect qRect = region2QRect( rControlRegion ); - - m_pScrollBar->move( qRect.topLeft() ); - m_pScrollBar->resize( qRect.size() ); - m_pScrollBar->setOrientation( bHorizontal? Qt::Horizontal: Qt::Vertical ); - - const ScrollbarValue* pValue = (aValue.getType() == ControlType::Scrollbar) ? static_cast<const ScrollbarValue*>(&aValue) : nullptr; - if ( pValue ) - { - m_pScrollBar->setMinValue( pValue->mnMin ); - m_pScrollBar->setMaxValue( pValue->mnMax - pValue->mnVisibleSize ); - m_pScrollBar->setValue( pValue->mnCur ); - m_pScrollBar->setPageStep( pValue->mnVisibleSize ); - } - - return m_pScrollBar; -} - -QToolBar *WidgetPainter::toolBar( const tools::Rectangle& rControlRegion, bool bHorizontal ) -{ - if ( !m_pMainWindow ) - m_pMainWindow = new QMainWindow( nullptr, "main_window" ); - - QToolBar *pToolBar; - if ( bHorizontal ) - { - if ( !m_pToolBarHoriz ) - { - m_pToolBarHoriz = new QToolBar( m_pMainWindow, "tool_bar_horiz" ); - m_pMainWindow->moveDockWindow( m_pToolBarHoriz, Qt::DockTop ); - } - pToolBar = m_pToolBarHoriz; - } - else - { - if ( !m_pToolBarVert ) - { - m_pToolBarVert = new QToolBar( m_pMainWindow, "tool_bar_horiz" ); - m_pMainWindow->moveDockWindow( m_pToolBarVert, Qt::DockLeft ); - } - pToolBar = m_pToolBarVert; - } - - QRect qRect = region2QRect( rControlRegion ); - - pToolBar->move( qRect.topLeft() ); - pToolBar->resize( qRect.size() ); - - return pToolBar; -} - -QToolButton *WidgetPainter::toolButton( const tools::Rectangle& rControlRegion) -{ - if ( !m_pToolButton ) - m_pToolButton = new QToolButton( nullptr, "tool_button" ); - - QRect qRect = region2QRect( rControlRegion ); - - m_pToolButton->move( qRect.topLeft() ); - m_pToolButton->resize( qRect.size() ); - - return m_pToolButton; -} - -QMenuBar *WidgetPainter::menuBar( const tools::Rectangle& rControlRegion) -{ - if ( !m_pMenuBar ) - { - m_pMenuBar = new QMenuBar( nullptr, "menu_bar" ); - - m_nMenuBarEnabledItem = m_pMenuBar->insertItem( "" ); - m_nMenuBarDisabledItem = m_pMenuBar->insertItem( "" ); - - m_pMenuBar->setItemEnabled( m_nMenuBarEnabledItem, true ); - m_pMenuBar->setItemEnabled( m_nMenuBarDisabledItem, false ); - } - - QRect qRect = region2QRect( rControlRegion ); - - m_pMenuBar->move( qRect.topLeft() ); - m_pMenuBar->resize( qRect.size() ); - - return m_pMenuBar; -} - -QPopupMenu *WidgetPainter::popupMenu( const tools::Rectangle& rControlRegion) -{ - if ( !m_pPopupMenu ) - { - m_pPopupMenu = new QPopupMenu( nullptr, "popup_menu" ); - - m_nPopupMenuEnabledItem = m_pPopupMenu->insertItem( "" ); - m_nPopupMenuDisabledItem = m_pPopupMenu->insertItem( "" ); - - m_pPopupMenu->setItemEnabled( m_nPopupMenuEnabledItem, true ); - m_pPopupMenu->setItemEnabled( m_nPopupMenuDisabledItem, false ); - } - - QRect qRect = region2QRect( rControlRegion ); - - m_pPopupMenu->move( qRect.topLeft() ); - m_pPopupMenu->resize( qRect.size() ); - - return m_pPopupMenu; -} - -QProgressBar *WidgetPainter::progressBar( const tools::Rectangle& rControlRegion ) -{ - if ( !m_pProgressBar ) - m_pProgressBar = new QProgressBar( nullptr, "progress_bar" ); - - QRect qRect = region2QRect( rControlRegion ); - - m_pProgressBar->move( qRect.topLeft() ); - m_pProgressBar->resize( qRect.size() ); - - return m_pProgressBar; -} - -QRect WidgetPainter::region2QRect( const tools::Rectangle& rControlRegion ) -{ - return QRect( QPoint( rControlRegion.Left(), rControlRegion.Top() ), - QPoint( rControlRegion.Right(), rControlRegion.Bottom() ) ); -} - -/** Instance of WidgetPainter. - - It is used to paint the widgets requested by NWF. -*/ -static WidgetPainter *pWidgetPainter; - -class KDESalGraphics : public X11SalGraphics -{ - public: - KDESalGraphics() {} - virtual bool IsNativeControlSupported( ControlType nType, ControlPart nPart ) override; - virtual bool hitTestNativeControl( ControlType nType, ControlPart nPart, - const tools::Rectangle& rControlRegion, const Point& aPos, - bool& rIsInside ) override; - virtual bool drawNativeControl( ControlType nType, ControlPart nPart, - const tools::Rectangle& rControlRegion, ControlState nState, - const ImplControlValue& aValue, - const OUString& aCaption ) override; - virtual bool getNativeControlRegion( ControlType nType, ControlPart nPart, - const tools::Rectangle& rControlRegion, ControlState nState, - const ImplControlValue& aValue, - const OUString& aCaption, - tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion ) override; -}; - -bool KDESalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nPart ) -{ - return - ( (nType == ControlType::Pushbutton) && (nPart == ControlPart::Entire) ) || - ( (nType == ControlType::Radiobutton) && (nPart == ControlPart::Entire) ) || - ( (nType == ControlType::Checkbox) && (nPart == ControlPart::Entire) ) || - ( (nType == ControlType::Combobox) && (nPart == ControlPart::Entire || nPart == ControlPart::HasBackgroundTexture) ) || - ( (nType == ControlType::Editbox) && (nPart == ControlPart::Entire || nPart == ControlPart::HasBackgroundTexture) ) || - ( (nType == ControlType::Listbox) && (nPart == ControlPart::Entire || nPart == ControlPart::ListboxWindow || nPart == ControlPart::HasBackgroundTexture ) ) || - ( (nType == ControlType::Spinbox) && (nPart == ControlPart::Entire || nPart == ControlPart::HasBackgroundTexture) ) || - // no ControlType::SpinButtons for KDE - ( (nType == ControlType::TabItem) && (nPart == ControlPart::Entire) ) || - ( (nType == ControlType::TabPane) && (nPart == ControlPart::Entire) ) || - // no ControlType::TabBody for KDE - ( (nType == ControlType::Scrollbar) && (nPart == ControlPart::Entire || nPart == ControlPart::DrawBackgroundHorz || nPart == ControlPart::DrawBackgroundVert) ) || - ( (nType == ControlType::Scrollbar) && (nPart == ControlPart::HasThreeButtons) ) || // TODO small optimization is possible here: return this only if the style really has 3 buttons - // ControlType::Fixedline not supported - ( (nType == ControlType::Toolbar) && (nPart == ControlPart::Entire || - nPart == ControlPart::DrawBackgroundHorz || nPart == ControlPart::DrawBackgroundVert || - nPart == ControlPart::ThumbHorz || nPart == ControlPart::ThumbVert || - nPart == ControlPart::Button) ) || - ( (nType == ControlType::Menubar) && (nPart == ControlPart::Entire || nPart == ControlPart::MenuItem) ) || - ( (nType == ControlType::MenuPopup) && (nPart == ControlPart::Entire || nPart == ControlPart::MenuItem) ) || - ( (nType == ControlType::Progress) && (nPart == ControlPart::Entire) ) - ; -} - -bool KDESalGraphics::hitTestNativeControl( ControlType nType, ControlPart nPart, - const tools::Rectangle& rControlRegion, const Point& rPos, - bool& rIsInside ) -{ - if ( nType == ControlType::Scrollbar ) - { - // make position relative to rControlRegion - Point aPos = rPos - rControlRegion.TopLeft(); - rIsInside = false; - - bool bHorizontal = ( nPart == ControlPart::ButtonLeft || nPart == ControlPart::ButtonRight ); - - QScrollBar *pScrollBar = pWidgetPainter->scrollBar( rControlRegion, - bHorizontal, ImplControlValue() ); - QRect qRectSubLine = QApplication::style().querySubControlMetrics( - QStyle::CC_ScrollBar, pScrollBar, QStyle::SC_ScrollBarSubLine ); - QRect qRectAddLine = QApplication::style().querySubControlMetrics( - QStyle::CC_ScrollBar, pScrollBar, QStyle::SC_ScrollBarAddLine ); - - // There are 2 buttons on the right/bottom side of the scrollbar - bool bTwoSubButtons = false; - - // It is a Platinum style scroll bar - bool bPlatinumStyle = false; - - // Workaround for Platinum and 3 button style scroll bars. - // It makes the right/down button bigger. - if ( bHorizontal ) - { - qRectAddLine.setLeft( QApplication::style().querySubControlMetrics( - QStyle::CC_ScrollBar, pScrollBar, - QStyle::SC_ScrollBarAddPage ).right() + 1 ); - if ( qRectAddLine.width() > qRectSubLine.width() ) - bTwoSubButtons = true; - if ( qRectSubLine.left() > QApplication::style().querySubControlMetrics( QStyle::CC_ScrollBar, pScrollBar, QStyle::SC_ScrollBarSubPage ).left() ) - bPlatinumStyle = true; - } - else - { - qRectAddLine.setTop( QApplication::style().querySubControlMetrics( - QStyle::CC_ScrollBar, pScrollBar, - QStyle::SC_ScrollBarAddPage ).bottom() + 1 ); - if ( qRectAddLine.height() > qRectSubLine.height() ) - bTwoSubButtons = true; - if ( qRectSubLine.top() > QApplication::style().querySubControlMetrics( QStyle::CC_ScrollBar, pScrollBar, QStyle::SC_ScrollBarSubPage ).top() ) - bPlatinumStyle = true; - } - - switch ( nPart ) - { - case ControlPart::ButtonLeft: - if ( !bPlatinumStyle && qRectSubLine.contains( aPos.getX(), aPos.getY() ) ) - rIsInside = true; - else if ( bTwoSubButtons ) - { - qRectAddLine.setWidth( qRectAddLine.width() / 2 ); - rIsInside = qRectAddLine.contains( aPos.getX(), aPos.getY() ); - } - break; - - case ControlPart::ButtonUp: - if ( !bPlatinumStyle && qRectSubLine.contains( aPos.getX(), aPos.getY() ) ) - rIsInside = true; - else if ( bTwoSubButtons ) - { - qRectAddLine.setHeight( qRectAddLine.height() / 2 ); - rIsInside = qRectAddLine.contains( aPos.getX(), aPos.getY() ); - } - break; - - case ControlPart::ButtonRight: - if ( bTwoSubButtons ) - qRectAddLine.setLeft( qRectAddLine.left() + qRectAddLine.width() / 2 ); - - rIsInside = qRectAddLine.contains( aPos.getX(), aPos.getY() ); - break; - - case ControlPart::ButtonDown: - if ( bTwoSubButtons ) - qRectAddLine.setTop( qRectAddLine.top() + qRectAddLine.height() / 2 ); - - rIsInside = qRectAddLine.contains( aPos.getX(), aPos.getY() ); - break; - - // cases ControlPart::TrackHorzArea and ControlPart::TrackVertArea - default: - return false; - } - - return true; - } - - return false; -} - -bool KDESalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, - const tools::Rectangle& rControlRegion, ControlState nState, - const ImplControlValue& aValue, - const OUString& ) -{ - bool bReturn = false; - - if ( (nType == ControlType::Pushbutton) && (nPart == ControlPart::Entire) ) - { - bReturn = pWidgetPainter->drawStyledWidget( - pWidgetPainter->pushButton( rControlRegion, bool(nState & ControlState::DEFAULT) ), - nState, aValue, this ); - } - else if ( (nType == ControlType::Radiobutton) && (nPart == ControlPart::Entire) ) - { - bReturn = pWidgetPainter->drawStyledWidget( - pWidgetPainter->radioButton( rControlRegion ), - nState, aValue, this ); - } - else if ( (nType == ControlType::Checkbox) && (nPart == ControlPart::Entire) ) - { - bReturn = pWidgetPainter->drawStyledWidget( - pWidgetPainter->checkBox( rControlRegion ), - nState, aValue, this ); - } - else if ( (nType == ControlType::Combobox) && (nPart == ControlPart::Entire) ) - { - bReturn = pWidgetPainter->drawStyledWidget( - pWidgetPainter->comboBox( rControlRegion, true ), - nState, aValue, this ); - } - else if ( (nType == ControlType::Editbox) && (nPart == ControlPart::Entire) ) - { - bReturn = pWidgetPainter->drawStyledWidget( - pWidgetPainter->lineEdit( rControlRegion ), - nState, aValue, this ); - } - else if ( (nType == ControlType::Listbox) && (nPart == ControlPart::Entire) ) - { - bReturn = pWidgetPainter->drawStyledWidget( - pWidgetPainter->comboBox( rControlRegion, false ), - nState, aValue, this ); - } - else if ( (nType == ControlType::Listbox) && (nPart == ControlPart::ListboxWindow) ) - { - bReturn = pWidgetPainter->drawStyledWidget( - pWidgetPainter->listView( rControlRegion ), - nState, aValue, this ); - } - else if ( (nType == ControlType::Spinbox) && (nPart == ControlPart::Entire) ) - { - bReturn = pWidgetPainter->drawStyledWidget( - pWidgetPainter->spinWidget( rControlRegion ), - nState, aValue, this ); - } - else if ( (nType==ControlType::TabItem) && (nPart == ControlPart::Entire) ) - { - bReturn = pWidgetPainter->drawStyledWidget( - pWidgetPainter->tabBar( rControlRegion ), - nState, aValue, this ); - } - else if ( (nType==ControlType::TabPane) && (nPart == ControlPart::Entire) ) - { - bReturn = pWidgetPainter->drawStyledWidget( - pWidgetPainter->tabWidget( rControlRegion ), - nState, aValue, this ); - } - else if ( (nType == ControlType::Scrollbar) && (nPart == ControlPart::DrawBackgroundHorz || nPart == ControlPart::DrawBackgroundVert) ) - { - bReturn = pWidgetPainter->drawStyledWidget( - pWidgetPainter->scrollBar( rControlRegion, nPart == ControlPart::DrawBackgroundHorz, aValue ), - nState, aValue, this ); - } - else if ( (nType == ControlType::Toolbar) && (nPart == ControlPart::DrawBackgroundHorz || nPart == ControlPart::DrawBackgroundVert || nPart == ControlPart::ThumbHorz || nPart == ControlPart::ThumbVert) ) - { - bReturn = pWidgetPainter->drawStyledWidget( - pWidgetPainter->toolBar( rControlRegion, nPart == ControlPart::DrawBackgroundHorz || nPart == ControlPart::ThumbVert ), - nState, aValue, this, nPart ); - } - else if ( (nType == ControlType::Toolbar) && (nPart == ControlPart::Button) ) - { - bReturn = pWidgetPainter->drawStyledWidget( - pWidgetPainter->toolButton( rControlRegion ), - nState, aValue, this, nPart ); - } - else if ( (nType == ControlType::Menubar) && (nPart == ControlPart::Entire || nPart == ControlPart::MenuItem) ) - { - bReturn = pWidgetPainter->drawStyledWidget( - pWidgetPainter->menuBar( rControlRegion ), - nState, aValue, this, nPart ); - } - else if ( (nType == ControlType::MenuPopup) && (nPart == ControlPart::Entire || nPart == ControlPart::MenuItem) ) - { - bReturn = pWidgetPainter->drawStyledWidget( - pWidgetPainter->popupMenu( rControlRegion ), - nState, aValue, this ); - } - else if ( (nType == ControlType::Progress) && (nPart == ControlPart::Entire) ) - { - bReturn = pWidgetPainter->drawStyledWidget( - pWidgetPainter->progressBar( rControlRegion ), - nState, aValue, this ); - } - - return bReturn; -} - -bool KDESalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPart, - const tools::Rectangle& rControlRegion, ControlState nState, - const ImplControlValue&, - const OUString&, - tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion ) -{ - bool bReturn = false; - QRect qBoundingRect = WidgetPainter::region2QRect( rControlRegion ); - QRect qRect; - - QWidget *pWidget = nullptr; - switch ( nType ) - { - // Metrics of the push button - case ControlType::Pushbutton: - pWidget = pWidgetPainter->pushButton( rControlRegion, bool( nState & ControlState::DEFAULT ) ); - - switch ( nPart ) - { - case ControlPart::Entire: - qRect = qBoundingRect; - - if ( nState & ControlState::DEFAULT ) - { - int nIndicatorSize = QApplication::style().pixelMetric( - QStyle::PM_ButtonDefaultIndicator, pWidget ); - qBoundingRect.addCoords( -nIndicatorSize, -nIndicatorSize, - nIndicatorSize, nIndicatorSize ); - bReturn = true; - } - break; - default: - break; - } - break; - - // Metrics of the radio button - case ControlType::Radiobutton: - pWidget = pWidgetPainter->radioButton( rControlRegion ); - - if ( nPart == ControlPart::Entire ) - { - qRect.setWidth( QApplication::style().pixelMetric( QStyle::PM_ExclusiveIndicatorWidth, pWidget ) ); - qRect.setHeight( QApplication::style().pixelMetric( QStyle::PM_ExclusiveIndicatorHeight, pWidget ) ); - - bReturn = true; - } - break; - - // Metrics of the check box - case ControlType::Checkbox: - pWidget = pWidgetPainter->checkBox( rControlRegion ); - - if ( nPart == ControlPart::Entire ) - { - qRect.setWidth( QApplication::style().pixelMetric( QStyle::PM_IndicatorWidth, pWidget ) ); - qRect.setHeight( QApplication::style().pixelMetric( QStyle::PM_IndicatorHeight, pWidget ) ); - - bReturn = true; - } - break; - - // Metrics of the combo box - case ControlType::Combobox: - case ControlType::Listbox: - pWidget = pWidgetPainter->comboBox( rControlRegion, ( nType == ControlType::Combobox ) ); - switch ( nPart ) - { - case ControlPart::ButtonDown: - qRect = QApplication::style().querySubControlMetrics( - QStyle::CC_ComboBox, pWidget, QStyle::SC_ComboBoxArrow ); - qRect.setLeft( QApplication::style().querySubControlMetrics( - QStyle::CC_ComboBox, pWidget, - QStyle::SC_ComboBoxEditField ).right() + 1 ); - qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() ); - bReturn = true; - break; - - case ControlPart::SubEdit: - qRect = QApplication::style().querySubControlMetrics( - QStyle::CC_ComboBox, pWidget, QStyle::SC_ComboBoxEditField ); - qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() ); - bReturn = true; - break; - - default: - break; - } - break; - - // Metrics of the spin box - case ControlType::Spinbox: - pWidget = pWidgetPainter->spinWidget( rControlRegion ); - switch ( nPart ) - { - case ControlPart::ButtonUp: - qRect = QApplication::style().querySubControlMetrics( - QStyle::CC_SpinWidget, pWidget, QStyle::SC_SpinWidgetUp ); - bReturn = true; - qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() ); - break; - - case ControlPart::ButtonDown: - qRect = QApplication::style().querySubControlMetrics( - QStyle::CC_SpinWidget, pWidget, QStyle::SC_SpinWidgetDown ); - bReturn = true; - qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() ); - break; - - case ControlPart::SubEdit: - qRect = QApplication::style().querySubControlMetrics( - QStyle::CC_SpinWidget, pWidget, QStyle::SC_SpinWidgetEditField ); - qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() ); - bReturn = true; - break; - - default: - break; - } - break; - - // Metrics of the scroll bar - case ControlType::Scrollbar: - pWidget = pWidgetPainter->scrollBar( rControlRegion, - ( nPart == ControlPart::ButtonLeft || nPart == ControlPart::ButtonRight ), - ImplControlValue() ); - switch ( nPart ) - { - case ControlPart::ButtonLeft: - case ControlPart::ButtonUp: - qRect = QApplication::style().querySubControlMetrics( - QStyle::CC_ScrollBar, pWidget, QStyle::SC_ScrollBarSubLine ); - - // Workaround for Platinum style scroll bars. It makes the - // left/up button invisible. - if ( nPart == ControlPart::ButtonLeft ) - { - if ( qRect.left() > QApplication::style().querySubControlMetrics( - QStyle::CC_ScrollBar, pWidget, - QStyle::SC_ScrollBarSubPage ).left() ) - { - qRect.setLeft( 0 ); - qRect.setRight( 0 ); - } - } - else - { - if ( qRect.top() > QApplication::style().querySubControlMetrics( - QStyle::CC_ScrollBar, pWidget, - QStyle::SC_ScrollBarSubPage ).top() ) - { - qRect.setTop( 0 ); - qRect.setBottom( 0 ); - } - } - - qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() ); - - bReturn = true; - break; - - case ControlPart::ButtonRight: - case ControlPart::ButtonDown: - qRect = QApplication::style().querySubControlMetrics( - QStyle::CC_ScrollBar, pWidget, QStyle::SC_ScrollBarAddLine ); - - // Workaround for Platinum and 3 button style scroll bars. - // It makes the right/down button bigger. - if ( nPart == ControlPart::ButtonRight ) - qRect.setLeft( QApplication::style().querySubControlMetrics( - QStyle::CC_ScrollBar, pWidget, - QStyle::SC_ScrollBarAddPage ).right() + 1 ); - else - qRect.setTop( QApplication::style().querySubControlMetrics( - QStyle::CC_ScrollBar, pWidget, - QStyle::SC_ScrollBarAddPage ).bottom() + 1 ); - - qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() ); - - bReturn = true; - break; - default: - break; - } - break; - default: - break; - } - - // Fill rNativeBoundingRegion and rNativeContentRegion - if ( bReturn ) - { - // Bounding region - Point aBPoint( qBoundingRect.x(), qBoundingRect.y() ); - Size aBSize( qBoundingRect.width(), qBoundingRect.height() ); - rNativeBoundingRegion = tools::Rectangle( aBPoint, aBSize ); - - // vcl::Region of the content - Point aPoint( qRect.x(), qRect.y() ); - Size aSize( qRect.width(), qRect.height() ); - rNativeContentRegion = tools::Rectangle( aPoint, aSize ); - } - - return bReturn; -} - -// KDESalFrame implementation - -KDESalFrame::KDESalFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) : - X11SalFrame( pParent, nStyle ) -{ -} - -void KDESalFrame::Show( bool bVisible, bool bNoActivate ) -{ - if ( !GetParent() && ! (GetStyle() & SalFrameStyleFlags::INTRO) ) - { - KDEXLib* pXLib = static_cast<KDEXLib*>(GetDisplay()->GetXLib()); - pXLib->doStartup(); - } - X11SalFrame::Show( bVisible, bNoActivate ); -} - -/** Helper function to convert colors. -*/ -static Color toColor( const QColor &rColor ) -{ - return Color( rColor.red(), rColor.green(), rColor.blue() ); -} - -/** Helper function to read untranslated text entry from KConfig configuration repository. -*/ -static OUString readEntryUntranslated( KConfig *pConfig, const char *pKey ) -{ - return OUString::createFromAscii( pConfig->readEntryUntranslated( pKey ).ascii() ); -} - -/** Helper function to read color from KConfig configuration repository. -*/ -static Color readColor( KConfig *pConfig, const char *pKey ) -{ - return toColor( pConfig->readColorEntry( pKey ) ); -} - -/** Helper function to add information to Font from QFont. - - Mostly grabbed from the Gtk+ vclplug (salnativewidgets-gtk.cxx). -*/ -static vcl::Font toFont( const QFont &rQFont, const css::lang::Locale& rLocale ) -{ - psp::FastPrintFontInfo aInfo; - QFontInfo qFontInfo( rQFont ); - - // set family name - aInfo.m_aFamilyName = OUString( rQFont.family().utf8(), strlen( rQFont.family().utf8() ), RTL_TEXTENCODING_UTF8 ); - - // set italic - aInfo.m_eItalic = ( qFontInfo.italic()? ITALIC_NORMAL: ITALIC_NONE ); - - // set weight - int nWeight = qFontInfo.weight(); - if ( nWeight <= QFont::Light ) - aInfo.m_eWeight = WEIGHT_LIGHT; - else if ( nWeight <= QFont::Normal ) - aInfo.m_eWeight = WEIGHT_NORMAL; - else if ( nWeight <= QFont::DemiBold ) - aInfo.m_eWeight = WEIGHT_SEMIBOLD; - else if ( nWeight <= QFont::Bold ) - aInfo.m_eWeight = WEIGHT_BOLD; - else - aInfo.m_eWeight = WEIGHT_ULTRABOLD; - - // set width - int nStretch = rQFont.stretch(); - if ( nStretch <= QFont::UltraCondensed ) - aInfo.m_eWidth = WIDTH_ULTRA_CONDENSED; - else if ( nStretch <= QFont::ExtraCondensed ) - aInfo.m_eWidth = WIDTH_EXTRA_CONDENSED; - else if ( nStretch <= QFont::Condensed ) - aInfo.m_eWidth = WIDTH_CONDENSED; - else if ( nStretch <= QFont::SemiCondensed ) - aInfo.m_eWidth = WIDTH_SEMI_CONDENSED; - else if ( nStretch <= QFont::Unstretched ) - aInfo.m_eWidth = WIDTH_NORMAL; - else if ( nStretch <= QFont::SemiExpanded ) - aInfo.m_eWidth = WIDTH_SEMI_EXPANDED; - else if ( nStretch <= QFont::Expanded ) - aInfo.m_eWidth = WIDTH_EXPANDED; - else if ( nStretch <= QFont::ExtraExpanded ) - aInfo.m_eWidth = WIDTH_EXTRA_EXPANDED; - else - aInfo.m_eWidth = WIDTH_ULTRA_EXPANDED; - - SAL_INFO( "vcl.kde", "font name BEFORE system match: \"" << aInfo.m_aFamilyName << "\"" ); - - // match font to e.g. resolve "Sans" - psp::PrintFontManager::get().matchFont( aInfo, rLocale ); - - SAL_INFO( "vcl.kde", "font match " << - (aInfo.m_nID != 0 ? "succeeded" : "failed") << - ", name AFTER: \"" << aInfo.m_aFamilyName << "\"" ); - - // font height - int nPointHeight = qFontInfo.pointSize(); - if ( nPointHeight <= 0 ) - nPointHeight = rQFont.pointSize(); - - // Create the font - vcl::Font aFont( aInfo.m_aFamilyName, Size( 0, nPointHeight ) ); - if( aInfo.m_eWeight != WEIGHT_DONTKNOW ) - aFont.SetWeight( aInfo.m_eWeight ); - if( aInfo.m_eWidth != WIDTH_DONTKNOW ) - aFont.SetWidthType( aInfo.m_eWidth ); - if( aInfo.m_eItalic != ITALIC_DONTKNOW ) - aFont.SetItalic( aInfo.m_eItalic ); - if( aInfo.m_ePitch != PITCH_DONTKNOW ) - aFont.SetPitch( aInfo.m_ePitch ); - - return aFont; -} - -/** Implementation of KDE integration's main method. -*/ -void KDESalFrame::UpdateSettings( AllSettings& rSettings ) -{ - StyleSettings aStyleSettings( rSettings.GetStyleSettings() ); - bool bSetTitleFont = false; - - aStyleSettings.SetToolbarIconSize( ToolbarIconSize::Large ); - - // WM settings - KConfig *pConfig = KGlobal::config(); - if ( pConfig ) - { - pConfig->setGroup( "WM" ); - const char *pKey; - - pKey = "activeBackground"; - if ( pConfig->hasKey( pKey ) ) - aStyleSettings.SetActiveColor( readColor( pConfig, pKey ) ); - - pKey = "inactiveBackground"; - if ( pConfig->hasKey( pKey ) ) - aStyleSettings.SetDeactiveColor( readColor( pConfig, pKey ) ); - - pKey = "inactiveForeground"; - if ( pConfig->hasKey( pKey ) ) - aStyleSettings.SetDeactiveTextColor( readColor( pConfig, pKey ) ); - - pKey = "activeForeground"; - if ( pConfig->hasKey( pKey ) ) - aStyleSettings.SetActiveTextColor( readColor( pConfig, pKey ) ); - - pKey = "titleFont"; - if ( pConfig->hasKey( pKey ) ) - { - vcl::Font aFont = toFont( pConfig->readFontEntry( pKey ), rSettings.GetUILanguageTag().getLocale() ); - aStyleSettings.SetTitleFont( aFont ); - bSetTitleFont = true; - } - - pConfig->setGroup( "Icons" ); - - pKey = "Theme"; - if ( pConfig->hasKey( pKey ) ) - aStyleSettings.SetPreferredIconTheme( readEntryUntranslated( pConfig, pKey ) ); - } - - // General settings - QColorGroup qColorGroup = QApplication::palette().active(); - - Color aFore = toColor( qColorGroup.foreground() ); - Color aBack = toColor( qColorGroup.background() ); - Color aText = toColor( qColorGroup.text() ); - Color aBase = toColor( qColorGroup.base() ); - - // Foreground - aStyleSettings.SetRadioCheckTextColor( aFore ); - aStyleSettings.SetLabelTextColor( aFore ); - aStyleSettings.SetDialogTextColor( aFore ); - aStyleSettings.SetGroupTextColor( aFore ); - - // Text - aStyleSettings.SetFieldTextColor( aText ); - aStyleSettings.SetFieldRolloverTextColor( aText ); - aStyleSettings.SetWindowTextColor( aText ); - aStyleSettings.SetToolTextColor( aText ); - aStyleSettings.SetHelpTextColor( aText ); - - // Base - aStyleSettings.SetFieldColor( aBase ); - aStyleSettings.SetHelpColor( aBase ); - aStyleSettings.SetWindowColor( aBase ); - aStyleSettings.SetActiveTabColor( aBase ); - - // Buttons - aStyleSettings.SetButtonTextColor( toColor( qColorGroup.buttonText() ) ); - aStyleSettings.SetButtonRolloverTextColor( toColor( qColorGroup.buttonText() ) ); - - // Tabs - aStyleSettings.SetTabTextColor( toColor( qColorGroup.buttonText() ) ); - aStyleSettings.SetTabRolloverTextColor( toColor( qColorGroup.buttonText() ) ); - aStyleSettings.SetTabHighlightTextColor( toColor( qColorGroup.buttonText() ) ); - - // Disable color - aStyleSettings.SetDisableColor( toColor( qColorGroup.mid() ) ); - - // Workspace - aStyleSettings.SetWorkspaceColor( toColor( qColorGroup.mid() ) ); - - // Background - aStyleSettings.Set3DColors( aBack ); - aStyleSettings.SetFaceColor( aBack ); - aStyleSettings.SetInactiveTabColor( aBack ); - aStyleSettings.SetDialogColor( aBack ); - aStyleSettings.SetCheckedColorSpecialCase( ); - - // Selection - aStyleSettings.SetHighlightColor( toColor( qColorGroup.highlight() ) ); - aStyleSettings.SetHighlightTextColor( toColor( qColorGroup.highlightedText() ) ); - - // Font - vcl::Font aFont = toFont( QApplication::font(), rSettings.GetUILanguageTag().getLocale() ); - - aStyleSettings.SetAppFont( aFont ); - aStyleSettings.SetHelpFont( aFont ); - aStyleSettings.SetMenuFont( aFont ); // will be changed according to pMenuBar - aStyleSettings.SetToolFont( aFont ); // will be changed according to pToolBar - aStyleSettings.SetLabelFont( aFont ); - aStyleSettings.SetRadioCheckFont( aFont ); - aStyleSettings.SetPushButtonFont( aFont ); - aStyleSettings.SetFieldFont( aFont ); - aStyleSettings.SetIconFont( aFont ); - aStyleSettings.SetTabFont( aFont ); - aStyleSettings.SetGroupFont( aFont ); - - aFont.SetWeight( WEIGHT_BOLD ); - if( !bSetTitleFont ) - aStyleSettings.SetTitleFont( aFont ); - aStyleSettings.SetFloatTitleFont( aFont ); - - int flash_time = QApplication::cursorFlashTime(); - aStyleSettings.SetCursorBlinkTime( flash_time != 0 ? flash_time/2 : STYLE_CURSOR_NOBLINKTIME ); - - KMainWindow qMainWindow; - qMainWindow.createGUI( "/dev/null" ); // hack - - // Menu - aStyleSettings.SetSkipDisabledInMenus( true ); - KMenuBar *pMenuBar = qMainWindow.menuBar(); - if ( pMenuBar ) - { - // Color - QColorGroup qMenuCG = pMenuBar->colorGroup(); - - // Menu text and background color, theme specific - Color aMenuFore = toColor( qMenuCG.foreground() ); - Color aMenuBack = toColor( qMenuCG.background() ); - if ( QApplication::style().inherits( "LightStyleV2" ) || - QApplication::style().inherits( "LightStyleV3" ) || - ( QApplication::style().inherits( QMotifStyle_String ) && !QApplication::style().inherits( QSGIStyle_String ) ) || - QApplication::style().inherits( QWindowsStyle_String ) ) - { - aMenuFore = toColor( qMenuCG.buttonText() ); - aMenuBack = toColor( qMenuCG.button() ); - } - - aStyleSettings.SetMenuTextColor( aMenuFore ); - aStyleSettings.SetMenuBarTextColor( aStyleSettings.GetPersonaMenuBarTextColor().get_value_or( aMenuFore ) ); - aStyleSettings.SetMenuColor( aMenuBack ); - aStyleSettings.SetMenuBarColor( aMenuBack ); - aStyleSettings.SetMenuHighlightColor( toColor ( qMenuCG.highlight() ) ); - - // Menu items highlight text color, theme specific - if ( QApplication::style().inherits( "HighContrastStyle" ) || - QApplication::style().inherits( "KeramikStyle" ) || - QApplication::style().inherits( QWindowsStyle_String ) || - QApplication::style().inherits( "ThinKeramikStyle" ) || - QApplication::style().inherits( "PlastikStyle" ) ) - { - aStyleSettings.SetMenuHighlightTextColor( toColor ( qMenuCG.highlightedText() ) ); - } - else - aStyleSettings.SetMenuHighlightTextColor( aMenuFore ); - - // set special menubar highlight text color - if ( QApplication::style().inherits( "HighContrastStyle" ) ) - ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = toColor( qMenuCG.highlightedText() ); - else - ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = aMenuFore; - - // set menubar rollover color - if ( QApplication::style().styleHint( QStyle::SH_MenuBar_MouseTracking ) ) - { - aStyleSettings.SetMenuBarRolloverColor( toColor ( qMenuCG.highlight() ) ); - aStyleSettings.SetMenuBarRolloverTextColor( ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor ); - } - else - { - aStyleSettings.SetMenuBarRolloverColor( aMenuBack ); - aStyleSettings.SetMenuBarRolloverTextColor( aMenuFore ); - } - aStyleSettings.SetMenuBarHighlightTextColor(aStyleSettings.GetMenuHighlightTextColor()); - - // Font - aFont = toFont( pMenuBar->font(), rSettings.GetUILanguageTag().getLocale() ); - aStyleSettings.SetMenuFont( aFont ); - } - - // Tool bar - KToolBar *pToolBar = qMainWindow.toolBar(); - if ( pToolBar ) - { - aFont = toFont( pToolBar->font(), rSettings.GetUILanguageTag().getLocale() ); - aStyleSettings.SetToolFont( aFont ); - } - - // Scroll bar size - aStyleSettings.SetScrollBarSize( QApplication::style().pixelMetric( QStyle::PM_ScrollBarExtent ) ); - - rSettings.SetStyleSettings( aStyleSettings ); -} - -SalGraphics* KDESalFrame::AcquireGraphics() -{ - if( GetWindow() ) - { - for( int i = 0; i < nMaxGraphics; i++ ) - { - if( ! m_aGraphics[i].bInUse ) - { - m_aGraphics[i].bInUse = true; - if( ! m_aGraphics[i].pGraphics ) - { - m_aGraphics[i].pGraphics.reset (new KDESalGraphics() ); - m_aGraphics[i].pGraphics->Init( this, GetWindow(), GetScreenNumber() ); - } - return m_aGraphics[i].pGraphics.get(); - } - } - } - - return nullptr; -} - -void KDESalFrame::ReleaseGraphics( SalGraphics *pGraphics ) -{ - for( int i = 0; i < nMaxGraphics; i++ ) - { - if( m_aGraphics[i].pGraphics.get() == pGraphics ) - { - m_aGraphics[i].bInUse = false; - break; - } - } -} - -void KDESalFrame::updateGraphics( bool bClear ) -{ - Drawable aDrawable = bClear ? None : GetWindow(); - for( int i = 0; i < nMaxGraphics; i++ ) - { - if( m_aGraphics[i].bInUse ) - m_aGraphics[i].pGraphics->SetDrawable( aDrawable, GetScreenNumber() ); - } -} - -KDESalFrame::~KDESalFrame() -{ -} - -// KDESalInstance implementation - -SalFrame * KDESalInstance::CreateFrame( SalFrame *pParent, SalFrameStyleFlags nStyle ) -{ - return new KDESalFrame( pParent, nStyle ); -} - -uno::Reference< ui::dialogs::XFilePicker2 > KDESalInstance::createFilePicker( - const uno::Reference< uno::XComponentContext >& xMSF ) -{ - return uno::Reference< ui::dialogs::XFilePicker2 >( - new UnxFilePicker( xMSF ) ); -} - -SalX11Display* KDESalInstance::CreateDisplay() const -{ - return new SalKDEDisplay( QPaintDevice::x11AppDisplay() ); -} - -// KDESalData pieces - -// Create the widget painter so we have some control over -// the destruction sequence, so Qt doesn't die in action. - -void KDEData::initNWF() -{ - ImplSVData *pSVData = ImplGetSVData(); - // draw toolbars on separate lines - pSVData->maNWFData.mbDockingAreaSeparateTB = true; - - pWidgetPainter = new WidgetPainter(); -} - -void KDEData::deInitNWF() -{ - delete pWidgetPainter; - pWidgetPainter = nullptr; - - // We have to destroy the style early - QApplication::setStyle( nullptr ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |