[Libreoffice-commits] core.git: Branch 'private/jmux/kf5' - config_host/config_qt5.h.in config_host/config_vclplug.h.in config_host.mk.in configure.ac cui/Library_cui.mk cui/source RepositoryExternal.mk Repository.mk scp2/InstallScript_setup_osl.mk scp2/Module_scp2.mk shell/Module_shell.mk shell/source solenv/gbuild sysui/CustomTarget_share.mk vcl/CustomTarget_kf5_moc.mk vcl/headless vcl/inc vcl/Library_vclplug_kf5.mk vcl/Module_vcl.mk vcl/opengl vcl/quartz vcl/source vcl/unx vcl/win

Jan-Marek Glogowski glogow at fbihome.de
Mon Oct 23 13:57:56 UTC 2017


Rebased ref, commits from common ancestor:
commit da0764ec9e021ef6592ca629d8438d47ecc79895
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Mon Oct 23 13:19:46 2017 +0200

    KF5 dummy
    
    Change-Id: Id723d0ef26f6e0f255c758c2a2a014362b8d4c5c

diff --git a/Repository.mk b/Repository.mk
index 09c9ea20d0e6..4fd902e693ee 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -287,8 +287,11 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,gnome, \
 
 $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,kde, \
 	$(if $(ENABLE_KDE4),kde4be1) \
+	$(if $(ENABLE_KDE5),kde5be1) \
 	$(if $(USING_X11), \
 		$(if $(ENABLE_KDE4),vclplug_kde4) \
+		$(if $(ENABLE_KDE5),vclplug_kde5) \
+        $(if $(ENABLE_KF5),vclplug_kf5) \
 	) \
 ))
 
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index b1642dea4ca6..3be5be420fb4 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -3066,6 +3066,37 @@ endef
 
 endif # ENABLE_KDE4
 
+ifeq ($(ENABLE_KDE5),TRUE)
+
+define gb_LinkTarget__use_kde5
+$(call gb_LinkTarget_set_include,$(1),\
+	$(subst -isystem/,-isystem /,$(filter -I% -isystem%,$(subst -isystem /,-isystem/,$(KF5_CFLAGS)))) \
+	$$(INCLUDE) \
+)
+
+$(call gb_LinkTarget_add_defs,$(1),\
+	$(filter-out -I% -isystem%,$(subst -isystem /,-isystem/,$(KF5_CFLAGS))) \
+)
+
+$(call gb_LinkTarget_add_libs,$(1),\
+	$(KF5_LIBS) \
+)
+
+ifeq ($(COM),GCC)
+$(call gb_LinkTarget_add_cxxflags,$(1),\
+	-Wno-shadow \
+)
+endif
+
+endef
+
+else # !ENABLE_KDE5
+
+define gb_LinkTarget__use_kde5
+
+endef
+
+endif # ENABLE_KDE5
 
 # PYTHON
 # extra python_headers external because pyuno wrapper must not link python
diff --git a/config_host.mk.in b/config_host.mk.in
index f602bbc0802d..d73c5acefca6 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -142,6 +142,8 @@ export ENABLE_GTK_PRINT=@ENABLE_GTK_PRINT@
 export ENABLE_HEADLESS=@ENABLE_HEADLESS@
 export ENABLE_JAVA=@ENABLE_JAVA@
 export ENABLE_KDE4=@ENABLE_KDE4@
+export ENABLE_KDE5=@ENABLE_KDE5@
+export ENABLE_KF5=@ENABLE_KF5@
 export ENABLE_LPSOLVE=@ENABLE_LPSOLVE@
 export ENABLE_LTO=@ENABLE_LTO@
 export ENABLE_LWP=@ENABLE_LWP@
@@ -159,6 +161,7 @@ export ENABLE_OPTIMIZED=@ENABLE_OPTIMIZED@
 export ENABLE_PCH=@ENABLE_PCH@
 export ENABLE_PDFIMPORT=@ENABLE_PDFIMPORT@
 export ENABLE_PDFIUM=@ENABLE_PDFIUM@
+export ENABLE_QT5=@ENABLE_QT5@
 export ENABLE_RANDR=@ENABLE_RANDR@
 export ENABLE_RELEASE_BUILD=@ENABLE_RELEASE_BUILD@
 export ENABLE_REPORTBUILDER=@ENABLE_REPORTBUILDER@
@@ -298,6 +301,11 @@ export KDE4_LIBS=$(gb_SPACE)@KDE4_LIBS@
 export KDE4_GLIB_CFLAGS=$(gb_SPACE)@KDE4_GLIB_CFLAGS@
 export KDE4_GLIB_LIBS=$(gb_SPACE)@KDE4_GLIB_LIBS@
 export KDE4_HAVE_GLIB=@KDE4_HAVE_GLIB@
+export KF5_CFLAGS=$(gb_SPACE)@KF5_CFLAGS@
+export KF5_LIBS=$(gb_SPACE)@KF5_LIBS@
+export KF5_GLIB_CFLAGS=$(gb_SPACE)@KF5_GLIB_CFLAGS@
+export KF5_GLIB_LIBS=$(gb_SPACE)@KF5_GLIB_LIBS@
+export KF5_HAVE_GLIB=@KF5_HAVE_GLIB@
 export KRB5_LIBS=@KRB5_LIBS@
 export LCMS2_CFLAGS=$(gb_SPACE)@LCMS2_CFLAGS@
 export LCMS2_LIBS=$(gb_SPACE)@LCMS2_LIBS@
@@ -386,6 +394,7 @@ export MINGWCXX=@MINGWCXX@
 export MINGWSTRIP=@MINGWSTRIP@
 export ML_EXE=@ML_EXE@
 export MOC4=@MOC4@
+export MOC5=@MOC5@
 export MPL_SUBSET=@MPL_SUBSET@
 export MSGFMT=@MSGFMT@
 export MSGUNIQ=@MSGUNIQ@
@@ -458,6 +467,12 @@ export PYTHON_LIBS=$(gb_SPACE)@PYTHON_LIBS@
 export PYTHON_VERSION=@PYTHON_VERSION@
 export PYTHON_VERSION_MAJOR=@PYTHON_VERSION_MAJOR@
 export PYTHON_VERSION_MINOR=@PYTHON_VERSION_MINOR@
+export QT5_CFLAGS=$(gb_SPACE)@QT5_CFLAGS@
+export QT5_LIBS=$(gb_SPACE)@QT5_LIBS@
+export QT5_GLIB_CFLAGS=$(gb_SPACE)@QT5_GLIB_CFLAGS@
+export QT5_GLIB_LIBS=$(gb_SPACE)@QT5_GLIB_LIBS@
+export QT5_HAVE_GLIB=@QT5_HAVE_GLIB@
+export KRB5_LIBS=@KRB5_LIBS@
 export QXP_CFLAGS=$(gb_SPACE)@QXP_CFLAGS@
 export QXP_LIBS=$(gb_SPACE)@QXP_LIBS@
 export RANLIB=@RANLIB@
diff --git a/config_host/config_qt5.h.in b/config_host/config_qt5.h.in
new file mode 100644
index 000000000000..cdce1af7800c
--- /dev/null
+++ b/config_host/config_qt5.h.in
@@ -0,0 +1,10 @@
+/*
+Settings for QT5 integration.
+*/
+
+#ifndef CONFIG_QT5_H
+#define CONFIG_QT5_H
+
+#define QT5_HAVE_GLIB 0
+
+#endif
diff --git a/config_host/config_vclplug.h.in b/config_host/config_vclplug.h.in
index 510d0d25229c..b7b9624cdf79 100644
--- a/config_host/config_vclplug.h.in
+++ b/config_host/config_vclplug.h.in
@@ -9,5 +9,6 @@ Settings about which X11 desktops have support enabled.
 
 #define ENABLE_GTK 0
 #define ENABLE_KDE4 0
+#define ENABLE_KDE5 0
 
 #endif
diff --git a/configure.ac b/configure.ac
index 07df6eb7d9f0..6c72739017a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -571,6 +571,9 @@ linux-gnu*|k*bsd*-gnu*)
     build_gstreamer_1_0=yes
     build_gstreamer_0_10=yes
     test_kde4=yes
+    test_kde5=yes
+    test_qt5=yes
+    test_kf5=yes
     if test "$enable_fuzzers" != yes; then
         test_freetype=yes
         test_fontconfig=yes
@@ -664,6 +667,9 @@ freebsd*)
     build_gstreamer_1_0=yes
     build_gstreamer_0_10=yes
     test_kde4=yes
+    test_qt5=yes
+    test_kde5=yes
+    test_kf5=yes
     test_freetype=yes
     AC_MSG_CHECKING([the FreeBSD operating system release])
     if test -n "$with_os_version"; then
@@ -692,6 +698,9 @@ freebsd*)
     build_gstreamer_1_0=yes
     build_gstreamer_0_10=yes
     test_kde4=yes
+    test_qt5=yes
+    test_kde5=yes
+    test_kf5=yes
     test_freetype=yes
     PTHREAD_LIBS="-pthread -lpthread"
     _os=NetBSD
@@ -717,6 +726,9 @@ dragonfly*)
     build_gstreamer_1_0=yes
     build_gstreamer_0_10=yes
     test_kde4=yes
+    test_qt5=yes
+    test_kde5=yes
+    test_kf5=yes
     test_freetype=yes
     PTHREAD_LIBS="-pthread"
     _os=DragonFly
@@ -740,6 +752,9 @@ linux-android*)
     test_freetype=no
     test_gtk=no
     test_kde4=no
+    test_qt5=yes
+    test_kde5=no
+    test_kf5=yes
     test_randr=no
     test_xrender=no
     _os=Android
@@ -1177,6 +1192,24 @@ AC_ARG_ENABLE(kde4,
          KDE4 are available.]),
 ,)
 
+AC_ARG_ENABLE(qt5,
+    AS_HELP_STRING([--enable-qt5],
+        [Determines whether to use Qt5 vclplug on platforms where Qt5 is
+         available.]),
+,)
+
+AC_ARG_ENABLE(kf5,
+    AS_HELP_STRING([--enable-kf5],
+        [Determines whether to use KF5 vclplug on platforms where Qt5 and
+         KF5 are available.]),
+,)
+
+AC_ARG_ENABLE(kde5,
+    AS_HELP_STRING([--enable-kde5],
+        [Determines whether to use Qt5/KF5 vclplug on platforms where Qt5 and
+         KF5 are available.]),
+,)
+
 libo_FUZZ_ARG_ENABLE(gui,
     AS_HELP_STRING([--disable-gui],
         [Disable use of X11 or Wayland to reduce dependencies. Not related to the --headless
@@ -4530,6 +4563,7 @@ if test "$USING_X11" != TRUE; then
     build_gstreamer_1_0=no
     build_gstreamer_0_10=no
     test_kde4=no
+    test_kde5=no
     enable_cairo_canvas=no
 fi
 
@@ -9752,6 +9786,29 @@ if test "x$enable_kde4" = "xyes"; then
 fi
 AC_SUBST(ENABLE_KDE4)
 
+ENABLE_QT5=""
+if test "x$enable_qt5" = "xyes"; then
+    ENABLE_QT5="TRUE"
+    AC_DEFINE(ENABLE_QT5)
+    R="$R qt5"
+fi
+AC_SUBST(ENABLE_QT5)
+
+ENABLE_KDE5=""
+if test "x$enable_kde5" = "xyes"; then
+    ENABLE_KDE5="TRUE"
+    AC_DEFINE(ENABLE_KDE5)
+    R="$R kde5"
+fi
+AC_SUBST(ENABLE_KDE5)
+
+ENABLE_KF5=""
+if test "x$enable_kf5" = "xyes"; then
+    ENABLE_KF5="TRUE"
+    AC_DEFINE(ENABLE_KF5)
+    R="$R kf5"
+fi
+AC_SUBST(ENABLE_KF5)
 
 build_vcl_plugins="$R"
 if test -z "$build_vcl_plugins"; then
@@ -10628,13 +10685,13 @@ if test "$test_kde4" = "yes" -a "$ENABLE_KDE4" = "TRUE"; then
     fi
 
     dnl Check for qmake
-    AC_PATH_PROG( QMAKEQT4, qmake-qt4, no, [`dirname $qt4_header_dir`/bin:$QT4DIR/bin:$PATH] )
-    QMAKE4="$QMAKEQT4"
+    AC_PATH_PROGS( QMAKE4, [qmake-qt4 qmake], no, [`dirname $qt4_header_dir`/bin:$QT4DIR/bin:$PATH] )
     if test "$QMAKE4" = "no"; then
-        AC_PATH_PROG( QMAKE4, qmake, no, [`dirname $qt4_header_dir`/bin:$QT4DIR/bin:$PATH] )
-        if test "$QMAKE4" = "no"; then
-            AC_MSG_ERROR([Qmake not found.  Please specify
-the root of your Qt installation by exporting QT4DIR before running "configure".])
+        AC_MSG_ERROR([Qmake not found.  Please specify the root of your Qt4 installation by exporting QT4DIR before running "configure".])
+    else
+        qmake4_test_ver="`$QMAKE4 -v 2>&1 | sed -n -e '/^Using Qt version 4\./p'`"
+        if test -z "$qmake4_test_ver"; then
+            AC_MSG_ERROR([Wrong qmake for Qt4 found. Please specify the root of your Qt installation by exporting QT5DIR before running "configure".])
         fi
     fi
 
@@ -10834,6 +10891,270 @@ AC_SUBST(KDE4_GLIB_LIBS)
 AC_SUBST(KDE4_HAVE_GLIB)
 
 dnl ===================================================================
+dnl QT5 Integration
+dnl ===================================================================
+
+QT5_CFLAGS=""
+QT5_LIBS=""
+QMAKE5="qmake"
+MOC5="moc"
+QT5_GLIB_CFLAGS=""
+QT5_GLIB_LIBS=""
+QT5_HAVE_GLIB=""
+if test \( "$test_kde5" = "yes" -a "$ENABLE_KDE5" = "TRUE" \) -o \
+        \( "$test_kf5" = "yes" -a "$ENABLE_KF5" = "TRUE" \) -o \
+        \( "$test_qt5" = "yes" -a "$ENABLE_QT5" = "TRUE" \)
+then
+    qt5_incdirs="$QT5INC /usr/include/qt5 /usr/include $x_includes"
+    qt5_libdirs="$QT5LIB /usr/lib/qt5 /usr/lib $x_libraries"
+
+    if test -n "$supports_multilib"; then
+        qt5_libdirs="$qt5_libdirs /usr/lib64/qt5 /usr/lib64/qt /usr/lib64"
+    fi
+
+    qt5_test_include="QtWidgets/qapplication.h"
+    qt5_test_library="libQt5Widgets.so"
+
+    dnl Check for qmake5
+    AC_PATH_PROGS( QMAKE5, [qmake-qt5 qmake], no, [$QT5DIR/bin:$PATH] )
+    if test "$QMAKE5" = "no"; then
+        AC_MSG_ERROR([Qmake not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
+    else
+        qmake5_test_ver="`$QMAKE5 -v 2>&1 | sed -n -e '/^Using Qt version 5\./p'`"
+        if test -z "$qmake5_test_ver"; then
+            AC_MSG_ERROR([Wrong qmake for Qt5 found. Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
+        fi
+    fi
+
+    qt5_incdirs="`$QMAKE5 -query QT_INSTALL_HEADERS` $qt5_incdirs"
+    qt5_libdirs="`$QMAKE5 -query QT_INSTALL_LIBS` $qt5_libdirs"
+
+    AC_MSG_CHECKING([for Qt5 headers])
+    qt5_incdir="no"
+    for inc_dir in $qt5_incdirs; do
+        if test -r "$inc_dir/$qt5_test_include"; then
+            qt5_incdir="$inc_dir"
+            break
+        fi
+    done
+    AC_MSG_RESULT([$qt5_incdir])
+    if test "x$qt5_incdir" = "xno"; then
+        AC_MSG_ERROR([Qt5 headers not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
+    fi
+
+    AC_MSG_CHECKING([for Qt5 libraries])
+    qt5_libdir="no"
+    for lib_dir in $qt5_libdirs; do
+        if test -r "$lib_dir/$qt5_test_library"; then
+            qt5_libdir="$lib_dir"
+            break
+        fi
+    done
+    AC_MSG_RESULT([$qt5_libdir])
+    if test "x$qt5_libdir" = "xno"; then
+        AC_MSG_ERROR([Qt5 libraries not found.  Please specify the root of your Qt5 installation by exporting QT5DIR before running "configure".])
+    fi
+
+    dnl Check for Meta Object Compiler
+
+    AC_PATH_PROGS( MOC5, [moc-qt5 moc], no, [`dirname $qt5_libdir`/bin:$QT5DIR/bin:$PATH] )
+    if test "$MOC5" = "no"; then
+        AC_MSG_ERROR([Qt Meta Object Compiler not found.  Please specify
+the root of your Qt installation by exporting QT5DIR before running "configure".])
+    fi
+
+    # Glib is needed for properly handling Qt event loop with Qt's Glib integration enabled.
+    # Sets also QT5_GLIB_CFLAGS/QT5_GLIB_LIBS if successful.
+    PKG_CHECK_MODULES(QT5_GLIB,[glib-2.0 >= 2.4],
+        [
+            QT5_HAVE_GLIB=1
+            AC_DEFINE(QT5_HAVE_GLIB,1)
+            QT5_GLIB_CFLAGS=$(printf '%s' "$QT5_GLIB_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+            FilterLibs "${QT5_GLIB_LIBS}"
+            QT5_GLIB_LIBS="${filteredlibs}"
+
+            qt5_fix_warning=
+
+            AC_LANG_PUSH([C++])
+            # tst_exclude_socket_notifiers.moc:70:28: runtime error: member access within address 0x60d00000bb20 which does not point to an object of type 'QO
+            # 0x60d00000bb20: note: object is of type 'QObjectPrivate'
+            #  02 00 80 3a  90 8a 4e d2 3a 00 00 00  f0 b4 b9 a7 ff 7f 00 00  00 00 00 00 00 00 00 00  20 d8 4e d2
+            #               ^~~~~~~~~~~~~~~~~~~~~~~
+            #               vptr for 'QObjectPrivate'
+            save_CXX=$CXX
+            CXX=$(printf %s "$CXX" \
+                | sed -e 's/-fno-sanitize-recover\(=[[0-9A-Za-z,_-]]*\)*//')
+            save_CXXFLAGS=$CXXFLAGS
+            CXXFLAGS="$CXXFLAGS $QT5_CFLAGS"
+            save_LIBS=$LIBS
+            LIBS="$LIBS $QT5_LIBS"
+            AC_MSG_CHECKING([whether Qt has fixed ExcludeSocketNotifiers])
+            # Prepare meta object data
+            TSTBASE="tst_exclude_socket_notifiers"
+            TSTMOC="${SRC_ROOT}/vcl/unx/kde5/${TSTBASE}"
+            ln -fs "${TSTMOC}.hxx"
+            $MOC5 "${TSTBASE}.hxx" -o "${TSTBASE}.moc"
+
+            AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <cstdlib>
+#include "tst_exclude_socket_notifiers.moc"
+
+int main(int argc, char *argv[])
+{
+    QCoreApplication app(argc, argv);
+    exit(tst_processEventsExcludeSocket());
+    return 0;
+}
+            ]])],[
+                AC_MSG_RESULT([yes])
+            ],[
+                AC_MSG_RESULT([no])
+                AC_MSG_WARN([native Qt5 file pickers will be disabled at runtime])
+                if test -z "$qt5_fix_warning"; then
+                    add_warning "native QT5 file pickers will be disabled at runtime, Qt5 fixes needed"
+                fi
+                qt5_fix_warning=1
+                add_warning "  https://bugreports.qt-project.org/browse/QTBUG-37380 (needed)"
+            ])
+
+            # Remove meta object data
+            rm -f "${TSTBASE}."*
+
+            AC_MSG_CHECKING([whether Qt avoids QClipboard recursion caused by posted events])
+            # Prepare meta object data
+            TSTBASE="tst_exclude_posted_events"
+            TSTMOC="${SRC_ROOT}/vcl/unx/kde5/${TSTBASE}"
+            ln -fs "${TSTMOC}.hxx"
+            $MOC5 "${TSTBASE}.hxx" -o "${TSTBASE}.moc"
+
+            AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <cstdlib>
+#include "tst_exclude_posted_events.moc"
+
+int main(int argc, char *argv[])
+{
+    QCoreApplication app(argc, argv);
+    exit(tst_excludePostedEvents());
+    return 0;
+}
+            ]])],[
+                AC_MSG_RESULT([yes])
+            ],[
+                AC_MSG_RESULT([no])
+                AC_MSG_WARN([native QT5 file pickers will be disabled at runtime])
+                if test -z "$qt5_fix_warning"; then
+                    add_warning "native QT5 file pickers will be disabled at runtime, Qt5 fixes needed"
+                fi
+                qt5_fix_warning=1
+                add_warning "  https://bugreports.qt-project.org/browse/QTBUG-34614 (needed)"
+            ])
+
+            # Remove meta object data
+            rm -f "${TSTBASE}."*
+
+            if test -n "$qt5_fix_warning"; then
+                add_warning "  https://bugreports.qt-project.org/browse/QTBUG-38585 (recommended)"
+            fi
+
+            LIBS=$save_LIBS
+            CXXFLAGS=$save_CXXFLAGS
+            CXX=$save_CXX
+            AC_LANG_POP([C++])
+        ],
+        AC_MSG_WARN([[No Glib found, Qt5 support will not use native file pickers!]]))
+
+fi
+AC_SUBST(QT5_CFLAGS)
+AC_SUBST(QT5_LIBS)
+AC_SUBST(MOC5)
+AC_SUBST(QT5_GLIB_CFLAGS)
+AC_SUBST(QT5_GLIB_LIBS)
+AC_SUBST(QT5_HAVE_GLIB)
+
+dnl ===================================================================
+dnl KDE5 Integration
+dnl ===================================================================
+
+KF5_CFLAGS=""
+KF5_LIBS=""
+KF5_CONFIG="kf5-config"
+if test \( "$test_kde5" = "yes" -a "$ENABLE_KDE5" = "TRUE" \) -o \
+        \( "$test_kf5" = "yes" -a "$ENABLE_KF5" = "TRUE" \)
+then
+    kf5_incdirs="$KF5INC /usr/include /usr/include/KF5 $x_includes"
+    kf5_libdirs="$KF5LIB /usr/lib /usr/lib/kf5 /usr/lib/kf5/devel $x_libraries"
+    if test -n "$supports_multilib"; then
+        kf5_libdirs="$kf5_libdirs /usr/lib64 /usr/lib64/kf5 /usr/lib64/kf5/devel"
+    fi
+
+    kf5_test_include="kcoreaddons_version.h"
+    kf5_test_library="libKF5CoreAddons.so"
+    kf5_libdirs="$qt5_libdir $kf5_libdirs"
+
+    dnl kf5 KDE4 support compatibility installed
+    AC_PATH_PROG( KF5_CONFIG, $KF5_CONFIG, no, )
+    if test "$KF5_CONFIG" != "no"; then
+        kf5_incdirs="`$KF5_CONFIG --path include` $kf5_incdirs"
+        kf5_libdirs="`$KF5_CONFIG --path lib` $kf5_libdirs"
+    fi
+
+    dnl Check for KF5 headers
+    AC_MSG_CHECKING([for KF5 headers])
+    kf5_incdir="no"
+    for kf5_check in $kf5_incdirs; do
+        if test -r "$kf5_check/$kf5_test_include"; then
+            kf5_incdir="$kf5_check"
+            break
+        fi
+    done
+    AC_MSG_RESULT([$kf5_incdir])
+    if test "x$kf5_incdir" = "xno"; then
+        AC_MSG_ERROR([KF5 headers not found.  Please specify the root of your KF5 installation by exporting KF5DIR before running "configure".])
+    fi
+
+    dnl Check for KF5 libraries
+    AC_MSG_CHECKING([for KF5 libraries])
+    kf5_libdir="no"
+    for kf5_check in $kf5_libdirs; do
+        if test -r "$kf5_check/$kf5_test_library"; then
+            kf5_libdir="$kf5_check"
+            break
+        fi
+    done
+
+    AC_MSG_RESULT([$kf5_libdir])
+    if test "x$kf5_libdir" = "xno"; then
+        AC_MSG_ERROR([KF5 libraries not found.  Please specify the root of your KF5 installation by exporting KF5DIR before running "configure".])
+    fi
+
+    PKG_CHECK_MODULES(KF5_XCB,[xcb],,[AC_MSG_ERROR([XCB not installed])])
+
+    KF5_CFLAGS="-I$kf5_incdir -I$kf5_incdir/KCoreAddons -I$kf5_incdir/KI18n -I$kf5_incdir/KConfigCore -I$kf5_incdir/KWindowSystem -I$kf5_incdir/KIOCore -I$qt5_incdir -I$qt5_incdir/QtCore -I$qt5_incdir/QtGui -I$qt5_incdir/QtWidgets -I$qt5_incdir/QtNetwork -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT $KF5_XCB_CFLAGS"
+    KF5_LIBS="-L$kf5_libdir -lKF5CoreAddons -lKF5I18n -lKF5ConfigCore -lKF5WindowSystem -lKF5KIOCore -L$qt5_libdir -lQt5Core -lQt5Gui -lQt5Widgets -lQt5Network -lQt5X11Extras $KF5_XCB_LIBS"
+    KF5_CFLAGS=$(printf '%s' "$KF5_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+
+    AC_LANG_PUSH([C++])
+    save_CXXFLAGS=$CXXFLAGS
+    CXXFLAGS="$CXXFLAGS $KF5_CFLAGS"
+    AC_MSG_CHECKING([whether KDE is >= 5.0])
+       AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <kcoreaddons_version.h>
+
+int main(int argc, char **argv) {
+       if (KCOREADDONS_VERSION_MAJOR == 5 && KCOREADDONS_VERSION_MINOR >= 0) return 0;
+       else return 1;
+}
+       ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([KDE version too old])],[])
+    CXXFLAGS=$save_CXXFLAGS
+    AC_LANG_POP([C++])
+fi
+AC_SUBST(KF5_CFLAGS)
+AC_SUBST(KF5_LIBS)
+AC_SUBST(KF5_GLIB_CFLAGS)
+AC_SUBST(KF5_GLIB_LIBS)
+AC_SUBST(KF5_HAVE_GLIB)
+
+dnl ===================================================================
 dnl Test whether to include Evolution 2 support
 dnl ===================================================================
 AC_MSG_CHECKING([whether to enable evolution 2 support])
@@ -12372,6 +12693,7 @@ AC_CONFIG_HEADERS([config_host/config_liblangtag.h])
 AC_CONFIG_HEADERS([config_host/config_locales.h])
 AC_CONFIG_HEADERS([config_host/config_mpl.h])
 AC_CONFIG_HEADERS([config_host/config_kde4.h])
+AC_CONFIG_HEADERS([config_host/config_qt5.h])
 AC_CONFIG_HEADERS([config_host/config_oox.h])
 AC_CONFIG_HEADERS([config_host/config_options.h])
 AC_CONFIG_HEADERS([config_host/config_options_calc.h])
diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk
index c6dc353f59b4..b8112e7f48db 100644
--- a/cui/Library_cui.mk
+++ b/cui/Library_cui.mk
@@ -22,6 +22,7 @@ $(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_KDE4)),-DENABLE_KDE4) \
+    $(if $(filter TRUE,$(ENABLE_KDE5)),-DENABLE_KDE5) \
 ))
 
 $(eval $(call gb_Library_use_custom_headers,cui,\
diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index e34c7e7a35c6..62a557e126e3 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -207,7 +207,15 @@ namespace
         {
             const OUString &rDesktopEnvironment = Application::GetDesktopEnvironment();
 
-            if ( rDesktopEnvironment.equalsIgnoreAsciiCase("kde4") )
+            if ( rDesktopEnvironment.equalsIgnoreAsciiCase("kde5") )
+            {
+                #if ENABLE_KDE5
+                return OUString("com.sun.star.ui.dialogs.KDE5FilePicker" );
+                #else
+                return OUString();
+                #endif
+            }
+            else if ( rDesktopEnvironment.equalsIgnoreAsciiCase("kde4") )
             {
                 #if ENABLE_KDE4
                 return OUString("com.sun.star.ui.dialogs.KDE4FilePicker" );
diff --git a/scp2/InstallScript_setup_osl.mk b/scp2/InstallScript_setup_osl.mk
index 63121d2cdc75..6a472238acc3 100644
--- a/scp2/InstallScript_setup_osl.mk
+++ b/scp2/InstallScript_setup_osl.mk
@@ -35,7 +35,7 @@ $(eval $(call gb_InstallScript_use_modules,setup_osl,\
 	$(if $(filter TRUE,$(ENABLE_EVOAB2) $(ENABLE_GIO) $(ENABLE_GTK) $(ENABLE_GTK3)),\
 		scp2/gnome \
 	) \
-	$(if $(filter TRUE,$(ENABLE_KDE4)),\
+	$(if $(filter TRUE,$(ENABLE_KDE4) $(ENABLE_KDE5)),\
 		scp2/kde \
 	) \
 	$(if $(filter TRUE,$(ENABLE_ONLINE_UPDATE)),\
diff --git a/scp2/Module_scp2.mk b/scp2/Module_scp2.mk
index f2bc6f45c3c4..daabb5b8ea68 100644
--- a/scp2/Module_scp2.mk
+++ b/scp2/Module_scp2.mk
@@ -39,7 +39,7 @@ $(eval $(call gb_Module_add_targets,scp2,\
 	$(if $(filter TRUE,$(ENABLE_EVOAB2) $(ENABLE_GIO) $(ENABLE_GTK) $(ENABLE_GTK3)),\
 		InstallModule_gnome \
 	) \
-	$(if $(filter TRUE,$(ENABLE_KDE4)),\
+	$(if $(filter TRUE,$(ENABLE_KDE4) $(ENABLE_KDE5)),\
 		InstallModule_kde \
 	) \
 ))
diff --git a/shell/Module_shell.mk b/shell/Module_shell.mk
index d1a54b9cf9ea..5da2416b6662 100644
--- a/shell/Module_shell.mk
+++ b/shell/Module_shell.mk
@@ -36,6 +36,12 @@ $(eval $(call gb_Module_add_targets,shell,\
 ))
 endif
 
+ifeq ($(ENABLE_KDE5),TRUE)
+$(eval $(call gb_Module_add_targets,shell,\
+	Library_kde5be \
+))
+endif
+
 ifeq ($(OS),WNT)
 
 $(eval $(call gb_Module_add_targets,shell,\
diff --git a/shell/source/backends/kde4be/kde4access.cxx b/shell/source/backends/kde4be/kde4access.cxx
index ad1e417ad23f..94ec20558074 100644
--- a/shell/source/backends/kde4be/kde4access.cxx
+++ b/shell/source/backends/kde4be/kde4access.cxx
@@ -19,6 +19,8 @@
 
 #include "sal/config.h"
 
+#include "kde4access.hxx"
+
 #include <QtGui/QFont>
 #include <QtCore/QString>
 #include <kemailsettings.h>
@@ -32,8 +34,6 @@
 #include "rtl/string.h"
 #include "rtl/ustring.hxx"
 
-#include "kde4access.hxx"
-
 #define SPACE      ' '
 #define COMMA      ','
 #define SEMI_COLON ';'
diff --git a/solenv/gbuild/CppunitTest.mk b/solenv/gbuild/CppunitTest.mk
index d0410466f846..c1a0547fc4bb 100644
--- a/solenv/gbuild/CppunitTest.mk
+++ b/solenv/gbuild/CppunitTest.mk
@@ -227,6 +227,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_KDE5),$(call gb_Library_get_target,vclplug_kde5)) \
 	 )
 endif
 
diff --git a/sysui/CustomTarget_share.mk b/sysui/CustomTarget_share.mk
index 0b259ddadec5..88ac5d0a480c 100644
--- a/sysui/CustomTarget_share.mk
+++ b/sysui/CustomTarget_share.mk
@@ -14,6 +14,8 @@ ifeq ($(ENABLE_GIO),TRUE)
 	brand_URIPARAM := --urls
 else ifeq ($(ENABLE_KDE4),TRUE)
 	brand_URIPARAM := --urls
+else ifeq ($(ENABLE_KDE5),TRUE)
+	brand_URIPARAM := --urls
 else
 	brand_URIPARAM :=
 endif
diff --git a/vcl/CustomTarget_kf5_moc.mk b/vcl/CustomTarget_kf5_moc.mk
index 5be8f629ceec..46beb2a71d3b 100644
--- a/vcl/CustomTarget_kf5_moc.mk
+++ b/vcl/CustomTarget_kf5_moc.mk
@@ -10,7 +10,9 @@
 $(eval $(call gb_CustomTarget_CustomTarget,vcl/unx/kf5))
 
 $(call gb_CustomTarget_get_target,vcl/unx/kf5) : \
+	$(call gb_CustomTarget_get_workdir,vcl/unx/kf5)/Kf5Instance.moc \
 	$(call gb_CustomTarget_get_workdir,vcl/unx/kf5)/Kf5Timer.moc \
+	$(call gb_CustomTarget_get_workdir,vcl/unx/kf5)/Kf5Widget.moc \
 
 $(call gb_CustomTarget_get_workdir,vcl/unx/kf5)/%.moc : \
 		$(SRCDIR)/vcl/unx/kf5/%.hxx \
diff --git a/vcl/Library_vclplug_kf5.mk b/vcl/Library_vclplug_kf5.mk
index 7d4db7513340..61c679d800ba 100644
--- a/vcl/Library_vclplug_kf5.mk
+++ b/vcl/Library_vclplug_kf5.mk
@@ -19,6 +19,8 @@
 
 $(eval $(call gb_Library_Library,vclplug_kf5))
 
+$(eval $(call gb_Library_set_warnings_not_errors,vclplug_kf5))
+
 $(eval $(call gb_Library_use_custom_headers,vclplug_kf5,vcl/unx/kf5))
 
 $(eval $(call gb_Library_set_include,vclplug_kf5,\
@@ -57,28 +59,38 @@ $(eval $(call gb_Library_use_externals,vclplug_kf5,\
 	epoxy \
 ))
 
-ifneq ($(KF5_HAVE_GLIB),)
+ifneq ($(QT5_HAVE_GLIB),)
 $(eval $(call gb_Library_add_defs,vclplug_kf5,\
-    $(KF5_GLIB_CFLAGS) \
+    $(QT5_GLIB_CFLAGS) \
 ))
-
 $(eval $(call gb_Library_add_libs,vclplug_kf5,\
-    $(KF5_GLIB_LIBS) \
+    $(QT5_GLIB_LIBS) \
 ))
 endif
 
+$(eval $(call gb_Library_add_defs,vclplug_kf5,\
+    $(KF5_CFLAGS) \
+))
+$(eval $(call gb_Library_add_libs,vclplug_kf5,\
+    $(KF5_LIBS) \
+))
+
 $(eval $(call gb_Library_add_exception_objects,vclplug_kf5,\
+    vcl/unx/kf5/Kf5Bitmap \
     vcl/unx/kf5/Kf5Data \
     vcl/unx/kf5/Kf5Frame \
+    vcl/unx/kf5/Kf5FontFace \
     vcl/unx/kf5/Kf5Graphics \
     vcl/unx/kf5/Kf5Graphics_Controls \
     vcl/unx/kf5/Kf5Graphics_GDI \
     vcl/unx/kf5/Kf5Graphics_Text \
     vcl/unx/kf5/Kf5Instance \
     vcl/unx/kf5/Kf5Instance_Print \
+    vcl/unx/kf5/Kf5Object \
     vcl/unx/kf5/Kf5Printer \
     vcl/unx/kf5/Kf5Timer \
     vcl/unx/kf5/Kf5VirtualDevice \
+    vcl/unx/kf5/Kf5Widget \
 ))
 
 ifeq ($(OS),LINUX)
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index 0a96849d0588..2e7d505bf35d 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -83,6 +83,12 @@ $(eval $(call gb_Module_add_targets,vcl,\
 endif
 ifneq ($(ENABLE_KDE5),)
 $(eval $(call gb_Module_add_targets,vcl,\
+    CustomTarget_kde5_moc \
+    Library_vclplug_kde5 \
+))
+endif
+ifneq ($(ENABLE_KF5),)
+$(eval $(call gb_Module_add_targets,vcl,\
     CustomTarget_kf5_moc \
     Library_vclplug_kf5 \
 ))
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 3e37da8e374f..5b0500ba802c 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -577,7 +577,7 @@ void SvpSalGraphics::drawRect( long nX, long nY, long nWidth, long nHeight )
     m_aLineColor = aOrigLineColor;
 }
 
-void SvpSalGraphics::drawPolyLine(sal_uInt32 nPoints, SalPoint* pPtAry)
+void SvpSalGraphics::drawPolyLine(sal_uInt32 nPoints, const SalPoint* pPtAry)
 {
     basegfx::B2DPolygon aPoly;
     aPoly.append(basegfx::B2DPoint(pPtAry->mnX, pPtAry->mnY), nPoints);
diff --git a/vcl/headless/svptext.cxx b/vcl/headless/svptext.cxx
index 3751a0f217e7..8ed53c626f2e 100644
--- a/vcl/headless/svptext.cxx
+++ b/vcl/headless/svptext.cxx
@@ -25,7 +25,7 @@
 #include "impfontmetricdata.hxx"
 #include "CommonSalLayout.hxx"
 
-void SvpSalGraphics::SetFont( FontSelectPattern* pIFSD, int nFallbackLevel )
+void SvpSalGraphics::SetFont( const FontSelectPattern* pIFSD, int nFallbackLevel )
 {
     m_aTextRenderImpl.SetFont(pIFSD, nFallbackLevel);
 }
diff --git a/vcl/inc/PhysicalFontFace.hxx b/vcl/inc/PhysicalFontFace.hxx
index 051ffcb6c288..94d7eb5ebc44 100644
--- a/vcl/inc/PhysicalFontFace.hxx
+++ b/vcl/inc/PhysicalFontFace.hxx
@@ -72,7 +72,7 @@ public:
     // by using an PhysicalFontFace object as a factory for its corresponding
     // LogicalFontInstance can be extended to cache device and font instance
     // specific data
-    virtual LogicalFontInstance*  CreateFontInstance( FontSelectPattern& ) const = 0;
+    virtual LogicalFontInstance*  CreateFontInstance( const FontSelectPattern& ) const = 0;
     virtual PhysicalFontFace* Clone() const = 0;
 
     int                     GetHeight() const           { return mnHeight; }
diff --git a/vcl/inc/PhysicalFontFamily.hxx b/vcl/inc/PhysicalFontFamily.hxx
index 34548785c56d..b782c4fe69f4 100644
--- a/vcl/inc/PhysicalFontFamily.hxx
+++ b/vcl/inc/PhysicalFontFamily.hxx
@@ -20,6 +20,8 @@
 #ifndef INCLUDED_VCL_INC_PHYSICALFONTFAMILY_HXX
 #define INCLUDED_VCL_INC_PHYSICALFONTFAMILY_HXX
 
+#include <vcl/dllapi.h>
+
 #include <set>
 
 #include <unotools/fontcfg.hxx>
@@ -45,7 +47,7 @@ namespace o3tl {
     template<> struct typed_flags<FontTypeFaces> : is_typed_flags<FontTypeFaces, 0xff> {};
 };
 
-class PhysicalFontFamily
+class VCL_PLUGIN_PUBLIC PhysicalFontFamily
 {
 public:
                         PhysicalFontFamily( const OUString& rSearchName );
diff --git a/vcl/inc/fontattributes.hxx b/vcl/inc/fontattributes.hxx
index 83b68f89464b..5487ac621668 100644
--- a/vcl/inc/fontattributes.hxx
+++ b/vcl/inc/fontattributes.hxx
@@ -20,13 +20,14 @@
 #ifndef INCLUDED_VCL_INC_FONTATTRIBUTES_HXX
 #define INCLUDED_VCL_INC_FONTATTRIBUTES_HXX
 
+#include <vcl/dllapi.h>
 #include <rtl/ustring.hxx>
 #include <vcl/vclenum.hxx>
 
 
 /* The following class is extraordinarily similar to ImplFont. */
 
-class FontAttributes
+class VCL_DLLPUBLIC FontAttributes
 {
 public:
     explicit            FontAttributes();
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index 5879c1bfdf44..49b4afd95872 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -141,7 +141,7 @@ public:
     virtual void            SetROPFillColor( SalROPColor nROPColor ) override;
 
     virtual void            SetTextColor( SalColor nSalColor ) override;
-    virtual void            SetFont( FontSelectPattern*, int nFallbackLevel ) override;
+    virtual void            SetFont( const FontSelectPattern*, int nFallbackLevel ) override;
     virtual void            GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
     virtual const FontCharMapRef GetFontCharMap() const override;
     virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override;
@@ -178,7 +178,7 @@ public:
                                           basegfx::B2DLineJoin,
                                           css::drawing::LineCap,
                                           double fMiterMinimumAngle) override;
-    virtual void            drawPolyLine( sal_uInt32 nPoints, SalPoint* pPtAry ) override;
+    virtual void            drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry ) override;
     virtual void            drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ) override;
     virtual void            drawPolyPolygon( sal_uInt32 nPoly,
                                              const sal_uInt32* pPoints,
diff --git a/vcl/inc/impfontcharmap.hxx b/vcl/inc/impfontcharmap.hxx
index 197333a49b6e..67ba048153fa 100644
--- a/vcl/inc/impfontcharmap.hxx
+++ b/vcl/inc/impfontcharmap.hxx
@@ -51,7 +51,7 @@ private:
     int                 mnCharCount;      // covered codepoints
 };
 
-bool ParseCMAP( const unsigned char* pRawData, int nRawLength, CmapResult& );
+bool VCL_DLLPUBLIC ParseCMAP( const unsigned char* pRawData, int nRawLength, CmapResult& );
 
 #endif // INCLUDED_VCL_INC_IMPFONTCHARMAP_HXX
 
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 67efca02924e..7bc6644fdc48 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -244,7 +244,7 @@ public:
 
     virtual void drawRect( long nX, long nY, long nWidth, long nHeight ) override;
 
-    virtual void drawPolyLine( sal_uInt32 nPoints, SalPoint* pPtAry ) override;
+    virtual void drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry ) override;
 
     virtual void drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ) override;
 
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 9a9626719169..b2207c288441 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -63,7 +63,7 @@ public:
     virtual                         ~CoreTextFontFace() override;
 
     PhysicalFontFace*               Clone() const override;
-    LogicalFontInstance*            CreateFontInstance( FontSelectPattern& ) const override;
+    LogicalFontInstance*            CreateFontInstance( const FontSelectPattern& ) const override;
     sal_IntPtr                      GetFontId() const override;
 
     int                             GetFontTable( const char pTagName[5], unsigned char* ) const;
@@ -330,7 +330,7 @@ public:
     // set the text color to a specific color
     virtual void            SetTextColor( SalColor nSalColor ) override;
     // set the font
-    virtual void            SetFont( FontSelectPattern*, int nFallbackLevel ) override;
+    virtual void            SetFont( const FontSelectPattern*, int nFallbackLevel ) override;
     // get the current font's metrics
     virtual void            GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
     // get the repertoire of the current font
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index 23ecadde41c0..555ef7856206 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -124,7 +124,7 @@ public:
     virtual void                SetTextColor( SalColor nSalColor ) = 0;
 
     // set the font
-    virtual void                SetFont( FontSelectPattern*, int nFallbackLevel ) = 0;
+    virtual void                SetFont( const FontSelectPattern*, int nFallbackLevel ) = 0;
 
     // release the fonts
     void                        ReleaseFonts() { SetFont( nullptr, 0 ); }
@@ -447,7 +447,7 @@ protected:
 
     virtual void                drawRect( long nX, long nY, long nWidth, long nHeight ) = 0;
 
-    virtual void                drawPolyLine( sal_uInt32 nPoints, SalPoint* pPtAry ) = 0;
+    virtual void                drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry ) = 0;
 
     virtual void                drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ) = 0;
 
diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx
index bf81e394976a..1771afaeaee8 100644
--- a/vcl/inc/salgdiimpl.hxx
+++ b/vcl/inc/salgdiimpl.hxx
@@ -94,7 +94,7 @@ public:
 
     virtual void drawRect( long nX, long nY, long nWidth, long nHeight ) = 0;
 
-    virtual void drawPolyLine( sal_uInt32 nPoints, SalPoint* pPtAry ) = 0;
+    virtual void drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry ) = 0;
 
     virtual void drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ) = 0;
 
diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 04ec36d0e813..4218503d301c 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -247,7 +247,7 @@ namespace vcl
     int VCL_DLLPUBLIC OpenTTFontFile(const char *fname, sal_uInt32 facenum, TrueTypeFont** ttf);
 #endif
 
-    bool getTTCoverage(
+    bool VCL_DLLPUBLIC getTTCoverage(
         boost::optional<std::bitset<UnicodeCoverage::MAX_UC_ENUM>> & rUnicodeCoverage,
         boost::optional<std::bitset<CodePageCoverage::MAX_CP_ENUM>> & rCodePageCoverage,
         const unsigned char* pTable, size_t nLength);
diff --git a/vcl/inc/textrender.hxx b/vcl/inc/textrender.hxx
index ebcb7a081f7c..ca21add07484 100644
--- a/vcl/inc/textrender.hxx
+++ b/vcl/inc/textrender.hxx
@@ -35,7 +35,7 @@ public:
     virtual ~TextRenderImpl() {}
 
     virtual void                    SetTextColor( SalColor nSalColor ) = 0;
-    virtual void                    SetFont( FontSelectPattern*, int nFallbackLevel ) = 0;
+    virtual void                    SetFont( const FontSelectPattern*, int nFallbackLevel ) = 0;
     virtual void                    GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) = 0;
     virtual const FontCharMapRef    GetFontCharMap() const = 0;
     virtual bool                    GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const = 0;
diff --git a/vcl/inc/unx/cairotextrender.hxx b/vcl/inc/unx/cairotextrender.hxx
index 2e6d1a57d63e..8c5fb68cfd45 100644
--- a/vcl/inc/unx/cairotextrender.hxx
+++ b/vcl/inc/unx/cairotextrender.hxx
@@ -51,7 +51,7 @@ public:
 
 
     virtual void                SetTextColor( SalColor nSalColor ) override;
-    virtual void                SetFont( FontSelectPattern*, int nFallbackLevel ) override;
+    virtual void                SetFont( const FontSelectPattern*, int nFallbackLevel ) override;
     virtual void                GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
     virtual const FontCharMapRef GetFontCharMap() const override;
     virtual bool                GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override;
diff --git a/vcl/inc/unx/freetype_glyphcache.hxx b/vcl/inc/unx/freetype_glyphcache.hxx
index 93788953a3ad..ad1d8722fe04 100644
--- a/vcl/inc/unx/freetype_glyphcache.hxx
+++ b/vcl/inc/unx/freetype_glyphcache.hxx
@@ -113,7 +113,7 @@ private:
 public:
                             FreetypeFontFace( FreetypeFontInfo*, const FontAttributes& );
 
-    virtual LogicalFontInstance* CreateFontInstance( FontSelectPattern& ) const override;
+    virtual LogicalFontInstance* CreateFontInstance( const FontSelectPattern& ) const override;
     virtual PhysicalFontFace* Clone() const override   { return new FreetypeFontFace( *this ); }
     virtual sal_IntPtr      GetFontId() const override { return mpFreetypeFontInfo->GetFontId(); }
 };
diff --git a/vcl/inc/unx/gendata.hxx b/vcl/inc/unx/gendata.hxx
index 910eb091af5b..a7e96b1a975d 100644
--- a/vcl/inc/unx/gendata.hxx
+++ b/vcl/inc/unx/gendata.hxx
@@ -23,7 +23,7 @@ enum GenericUnixSalDataType { SAL_DATA_GTK, SAL_DATA_GTK3,
                               SAL_DATA_TDE3, SAL_DATA_KDE3, SAL_DATA_KDE4,
                               SAL_DATA_UNX, SAL_DATA_SVP,
                               SAL_DATA_ANDROID, SAL_DATA_IOS,
-                              SAL_DATA_HEADLESS, SAL_DATA_KF5 };
+                              SAL_DATA_HEADLESS, SAL_DATA_KDE5, SAL_DATA_KF5 };
 
 class VCL_DLLPUBLIC GenericUnixSalData : public SalData
 {
diff --git a/vcl/inc/unx/genpspgraphics.h b/vcl/inc/unx/genpspgraphics.h
index 49682011954b..39b61c799f39 100644
--- a/vcl/inc/unx/genpspgraphics.h
+++ b/vcl/inc/unx/genpspgraphics.h
@@ -83,7 +83,7 @@ public:
     virtual void            SetROPFillColor( SalROPColor nROPColor ) override;
 
     virtual void            SetTextColor( SalColor nSalColor ) override;
-    virtual void            SetFont( FontSelectPattern*, int nFallbackLevel ) override;
+    virtual void            SetFont( const FontSelectPattern*, int nFallbackLevel ) override;
     virtual void            GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
     virtual const FontCharMapRef GetFontCharMap() const override;
     virtual bool            GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override;
@@ -120,7 +120,7 @@ public:
     virtual void            drawPixel( long nX, long nY, SalColor nSalColor ) override;
     virtual void            drawLine( long nX1, long nY1, long nX2, long nY2 ) override;
     virtual void            drawRect( long nX, long nY, long nWidth, long nHeight ) override;
-    virtual void            drawPolyLine( sal_uInt32 nPoints, SalPoint* pPtAry ) override;
+    virtual void            drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry ) override;
     virtual void            drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ) override;
     virtual void            drawPolyPolygon( sal_uInt32 nPoly,
                                              const sal_uInt32* pPoints,
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index 8e5045ff4f01..bcfadbd35e3b 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -115,7 +115,7 @@ public:
     virtual void                    SetROPFillColor( SalROPColor nROPColor ) override;
 
     virtual void                    SetTextColor( SalColor nSalColor ) override;
-    virtual void                    SetFont( FontSelectPattern*, int nFallbackLevel ) override;
+    virtual void                    SetFont( const FontSelectPattern*, int nFallbackLevel ) override;
     virtual void                    GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
     virtual const FontCharMapRef    GetFontCharMap() const override;
     virtual bool                    GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override;
@@ -151,7 +151,7 @@ public:
     virtual void                    drawPixel( long nX, long nY, SalColor nSalColor ) override;
     virtual void                    drawLine( long nX1, long nY1, long nX2, long nY2 ) override;
     virtual void                    drawRect( long nX, long nY, long nWidth, long nHeight ) override;
-    virtual void                    drawPolyLine( sal_uInt32 nPoints, SalPoint* pPtAry ) override;
+    virtual void                    drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry ) override;
     virtual void                    drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ) override;
 
     virtual void                    drawPolyPolygon(
diff --git a/vcl/inc/unx/tde/tdedata.hxx b/vcl/inc/unx/tde/tdedata.hxx
deleted file mode 100644
index d8f1363f2f95..000000000000
--- a/vcl/inc/unx/tde/tdedata.hxx
+++ /dev/null
@@ -1,114 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- * Copyright 2012 Timothy Pearson
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org.  If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef INCLUDED_VCL_INC_UNX_TDE_TDEDATA_HXX
-#define INCLUDED_VCL_INC_UNX_TDE_TDEDATA_HXX
-
-#include <unx/saldisp.hxx>
-#include <unx/saldata.hxx>
-#include <unx/salframe.h>
-
-class TDEData : public X11SalData
-{
-public:
-    TDEData( SalInstance *pInstance ) : X11SalData( SAL_DATA_TDE, pInstance ) {}
-    virtual ~TDEData();
-
-    virtual void Init();
-    virtual void initNWF();
-    virtual void deInitNWF();
-};
-
-class SalTDEDisplay : public SalX11Display
-{
-public:
-    SalTDEDisplay( Display* pDisp );
-    virtual ~SalTDEDisplay();
-};
-
-class TDESalFrame : public X11SalFrame
-{
-    static const int nMaxGraphics = 2;
-
-    struct GraphicsHolder
-    {
-        X11SalGraphics*     pGraphics;
-        bool                bInUse;
-        GraphicsHolder()
-                : pGraphics( NULL ),
-                  bInUse( false )
-        {}
-        ~GraphicsHolder();
-    };
-    GraphicsHolder m_aGraphics[ nMaxGraphics ];
-
-public:
-    TDESalFrame( SalFrame* pParent, SalFrameStyleFlags );
-    virtual ~TDESalFrame();
-
-    virtual SalGraphics* AcquireGraphics();
-    virtual void ReleaseGraphics( SalGraphics *pGraphics );
-    virtual void updateGraphics( bool bClear );
-    virtual void UpdateSettings( AllSettings& rSettings );
-    virtual void Show( bool bVisible, bool bNoActivate );
-};
-
-class TDESalInstance : public X11SalInstance
-{
-public:
-    TDESalInstance( SalYieldMutex* pMutex )
-            : X11SalInstance( pMutex ) {}
-    virtual ~TDESalInstance() {}
-    virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle );
-};
-
-class TDEXLib : public SalXLib
-{
-    bool            m_bStartupDone;
-    void*           m_pApplication;
-    char**          m_pFreeCmdLineArgs;
-    char**          m_pAppCmdLineArgs;
-    int             m_nFakeCmdLineArgs;
-public:
-    TDEXLib() : SalXLib(),
-        m_bStartupDone( false ),
-        m_pApplication( NULL ),
-        m_pFreeCmdLineArgs( NULL ),
-        m_pAppCmdLineArgs( NULL ),
-        m_nFakeCmdLineArgs( 0 )
-        {}
-    virtual ~TDEXLib();
-    virtual void Init();
-
-    void doStartup();
-};
-
-#endif // INCLUDED_VCL_INC_UNX_TDE_TDEDATA_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/vclpluginapi.h b/vcl/inc/vclpluginapi.h
index f536380c2423..3e20be8adf69 100644
--- a/vcl/inc/vclpluginapi.h
+++ b/vcl/inc/vclpluginapi.h
@@ -35,24 +35,18 @@
 #define VCLPLUG_GTK_PUBLIC SAL_DLLPUBLIC_IMPORT
 #endif
 
-#if defined VCLPLUG_TDE_IMPLEMENTATION
-#define VCLPLUG_TDE_PUBLIC SAL_DLLPUBLIC_EXPORT
-#else
-#define VCLPLUG_TDE_PUBLIC SAL_DLLPUBLIC_IMPORT
-#endif
-
-#if defined VCLPLUG_KDE_IMPLEMENTATION
-#define VCLPLUG_KDE_PUBLIC SAL_DLLPUBLIC_EXPORT
-#else
-#define VCLPLUG_KDE_PUBLIC SAL_DLLPUBLIC_IMPORT
-#endif
-
 #if defined VCLPLUG_KDE4_IMPLEMENTATION
 #define VCLPLUG_KDE4_PUBLIC SAL_DLLPUBLIC_EXPORT
 #else
 #define VCLPLUG_KDE4_PUBLIC SAL_DLLPUBLIC_IMPORT
 #endif
 
+#if defined VCLPLUG_KDE5_IMPLEMENTATION
+#define VCLPLUG_KDE5_PUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define VCLPLUG_KDE5_PUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+
 #if defined VCLPLUG_KF5_IMPLEMENTATION
 #define VCLPLUG_KF5_PUBLIC SAL_DLLPUBLIC_EXPORT
 #else
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index d975b5d70773..dedb1d9d0c20 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -65,7 +65,7 @@ public:
     virtual                 ~WinFontFace() override;
 
     virtual PhysicalFontFace* Clone() const override;
-    virtual LogicalFontInstance* CreateFontInstance( FontSelectPattern& ) const override;
+    virtual LogicalFontInstance* CreateFontInstance( const FontSelectPattern& ) const override;
     virtual sal_IntPtr      GetFontId() const override;
     void                    SetFontId( sal_IntPtr nId ) { mnId = nId; }
     void                    UpdateFromHDC( HDC ) const;
@@ -332,7 +332,7 @@ public:
     // set the text color to a specific color
     virtual void            SetTextColor( SalColor nSalColor ) override;
     // set the font
-    virtual void            SetFont( FontSelectPattern*, int nFallbackLevel ) override;
+    virtual void            SetFont( const FontSelectPattern*, int nFallbackLevel ) override;
     // get the current font's metrics
     virtual void            GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
     // get the repertoire of the current font
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index f24038ee8cc1..6cf8e0f0ee4e 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -1544,7 +1544,7 @@ void OpenGLSalGraphicsImpl::drawRect( long nX, long nY, long nWidth, long nHeigh
     PostBatchDraw();
 }
 
-void OpenGLSalGraphicsImpl::drawPolyLine( sal_uInt32 nPoints, SalPoint* pPtAry )
+void OpenGLSalGraphicsImpl::drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry )
 {
     VCL_GL_INFO("::drawPolyLine legacy -> redirecting to drawPolyLine");
     basegfx::B2DPolygon aPoly;
diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx
index 9c2acbd2de01..dbadea948e1f 100644
--- a/vcl/quartz/ctfonts.cxx
+++ b/vcl/quartz/ctfonts.cxx
@@ -268,7 +268,7 @@ PhysicalFontFace* CoreTextFontFace::Clone() const
     return new CoreTextFontFace( *this);
 }
 
-LogicalFontInstance* CoreTextFontFace::CreateFontInstance( /*const*/ FontSelectPattern& rFSD ) const
+LogicalFontInstance* CoreTextFontFace::CreateFontInstance( const FontSelectPattern& rFSD ) const
 {
     return new LogicalFontInstance( rFSD);
 }
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 42bb48ffefd4..37cb30d6fdfd 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -477,7 +477,7 @@ void AquaSalGraphics::DrawTextLayout(const CommonSalLayout& rLayout)
     CGContextRestoreGState(mrContext);
 }
 
-void AquaSalGraphics::SetFont(FontSelectPattern* pReqFont, int nFallbackLevel)
+void AquaSalGraphics::SetFont(const FontSelectPattern* pReqFont, int nFallbackLevel)
 {
     // release the text style
     for (int i = nFallbackLevel; i < MAX_FALLBACK; ++i)
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 16549094c6f0..5ffe45039791 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2230,7 +2230,7 @@ PdfBuiltinFontFace::PdfBuiltinFontFace( const PDFWriterImpl::BuiltinFont& rBuilt
     mrBuiltin( rBuiltin )
 {}
 
-LogicalFontInstance* PdfBuiltinFontFace::CreateFontInstance( FontSelectPattern& rFSD ) const
+LogicalFontInstance* PdfBuiltinFontFace::CreateFontInstance( const FontSelectPattern& rFSD ) const
 {
     LogicalFontInstance* pEntry = new LogicalFontInstance( rFSD );
     return pEntry;
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index f4e764879137..e96470735cc9 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -1300,7 +1300,7 @@ public:
     const PDFWriterImpl::BuiltinFont&   GetBuiltinFont() const  { return mrBuiltin; }
 
     virtual PhysicalFontFace*           Clone() const override { return new PdfBuiltinFontFace(*this); }
-    virtual LogicalFontInstance*        CreateFontInstance( FontSelectPattern& ) const override;
+    virtual LogicalFontInstance*        CreateFontInstance( const FontSelectPattern& ) const override;
     virtual sal_IntPtr                  GetFontId() const override { return reinterpret_cast<sal_IntPtr>(&mrBuiltin); }
 };
 
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index c3d0ecc42e75..681c22c60f25 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -337,7 +337,7 @@ bool CairoTextRender::GetFontCapabilities(vcl::FontCapabilities &rGetImplFontCap
 
 // SalGraphics
 
-void CairoTextRender::SetFont( FontSelectPattern *pEntry, int nFallbackLevel )
+void CairoTextRender::SetFont( const FontSelectPattern *pEntry, int nFallbackLevel )
 {
     setFont(pEntry, nFallbackLevel);
 }
diff --git a/vcl/unx/generic/gdi/font.cxx b/vcl/unx/generic/gdi/font.cxx
index 2e8dd081cf35..c9ce171f093a 100644
--- a/vcl/unx/generic/gdi/font.cxx
+++ b/vcl/unx/generic/gdi/font.cxx
@@ -70,7 +70,7 @@ bool X11SalGraphics::GetFontCapabilities(vcl::FontCapabilities &rGetImplFontCapa
 
 // SalGraphics
 
-void X11SalGraphics::SetFont( FontSelectPattern *pEntry, int nFallbackLevel )
+void X11SalGraphics::SetFont( const FontSelectPattern *pEntry, int nFallbackLevel )
 {
     mxTextRenderImpl->SetFont(pEntry, nFallbackLevel);
 }
diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx
index 8fc0361b0789..3928a82b178a 100644
--- a/vcl/unx/generic/gdi/gdiimpl.cxx
+++ b/vcl/unx/generic/gdi/gdiimpl.cxx
@@ -1240,7 +1240,7 @@ void X11SalGraphicsImpl::drawRect( long nX, long nY, long nDX, long nDY )
                         nX, nY, nDX-1, nDY-1 );
 }
 
-void X11SalGraphicsImpl::drawPolyLine( sal_uInt32 nPoints, SalPoint *pPtAry )
+void X11SalGraphicsImpl::drawPolyLine( sal_uInt32 nPoints, const SalPoint *pPtAry )
 {
     drawPolyLine( nPoints, pPtAry, false );
 }
diff --git a/vcl/unx/generic/gdi/gdiimpl.hxx b/vcl/unx/generic/gdi/gdiimpl.hxx
index 953ea731141f..9f404d16acc0 100644
--- a/vcl/unx/generic/gdi/gdiimpl.hxx
+++ b/vcl/unx/generic/gdi/gdiimpl.hxx
@@ -152,7 +152,7 @@ public:
 
     virtual void drawRect( long nX, long nY, long nWidth, long nHeight ) override;
 
-    virtual void drawPolyLine( sal_uInt32 nPoints, SalPoint* pPtAry ) override;
+    virtual void drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry ) override;
 
     virtual void drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ) override;
 
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index 861232597432..570e75fa05fe 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -431,7 +431,7 @@ void X11SalGraphics::drawRect( long nX, long nY, long nDX, long nDY )
     mxImpl->drawRect( nX, nY, nDX, nDY );
 }
 
-void X11SalGraphics::drawPolyLine( sal_uInt32 nPoints, SalPoint *pPtAry )
+void X11SalGraphics::drawPolyLine( sal_uInt32 nPoints, const SalPoint *pPtAry )
 {
     mxImpl->drawPolyLine( nPoints, pPtAry );
 }
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
index 534115115c54..5a2f6ba23cc5 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -354,7 +354,7 @@ FreetypeFontFace::FreetypeFontFace( FreetypeFontInfo* pFI, const FontAttributes&
 {
 }
 
-LogicalFontInstance* FreetypeFontFace::CreateFontInstance( FontSelectPattern& rFSD ) const
+LogicalFontInstance* FreetypeFontFace::CreateFontInstance( const FontSelectPattern& rFSD ) const
 {
     FreetypeFontInstance* pEntry = new FreetypeFontInstance( rFSD );
     return pEntry;
diff --git a/vcl/unx/generic/plugadapt/salplug.cxx b/vcl/unx/generic/plugadapt/salplug.cxx
index 441f16ddb113..09c708e9ab09 100644
--- a/vcl/unx/generic/plugadapt/salplug.cxx
+++ b/vcl/unx/generic/plugadapt/salplug.cxx
@@ -100,7 +100,7 @@ static SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = fals
                  * #i109007# KDE3 seems to have the same problem.
                  * And same applies for KDE4.
                  */
-                if( rModuleBase == "gtk" || rModuleBase == "gtk3" || rModuleBase == "tde" || rModuleBase == "kde" || rModuleBase == "kde4" )
+                if( rModuleBase == "gtk" || rModuleBase == "gtk3" || rModuleBase == "tde" || rModuleBase == "kde" || rModuleBase == "kde4" || rModuleBase == "kde5" )
                 {
                     pCloseModule = nullptr;
                 }
@@ -165,17 +165,12 @@ static DesktopType get_desktop_environment()
 
 static SalInstance* autodetect_plugin()
 {
-    static const char* const pTDEFallbackList[] =
-    {
-        "tde",
-#if ENABLE_KDE4
-        "kde4",
-#endif
-        "gtk3", "gtk", "gen", nullptr
-    };
-
     static const char* const pKDEFallbackList[] =
     {
+#if ENABLE_KDE5
+        "kf5",
+        "kde5",
+#endif
 #if ENABLE_KDE4
         "kde4",
 #endif
@@ -205,8 +200,6 @@ static SalInstance* autodetect_plugin()
               desktop == DESKTOP_KDE3 ||
               desktop == DESKTOP_MATE )
         pList = pStandardFallbackList;
-    else if( desktop == DESKTOP_TDE )
-        pList = pTDEFallbackList;
     else if( desktop == DESKTOP_KDE4 || desktop == DESKTOP_KDE5 )
         pList = pKDEFallbackList;
 
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index 6f458df680eb..27ad7f963ee6 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -396,15 +396,15 @@ void GenPspGraphics::drawRect( long nX, long nY, long nDX, long nDY )
     m_pPrinterGfx->DrawRect (tools::Rectangle(Point(nX, nY), Size(nDX, nDY)));
 }
 
-void GenPspGraphics::drawPolyLine( sal_uInt32 nPoints, SalPoint *pPtAry )
+void GenPspGraphics::drawPolyLine( sal_uInt32 nPoints, const SalPoint *pPtAry )
 {
-    m_pPrinterGfx->DrawPolyLine (nPoints, reinterpret_cast<Point *>(pPtAry));
+    m_pPrinterGfx->DrawPolyLine (nPoints, reinterpret_cast<const Point *>(pPtAry));
 }
 
 void GenPspGraphics::drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry )
 {
     // Point must be equal to SalPoint! see include/vcl/salgtype.hxx
-    m_pPrinterGfx->DrawPolygon (nPoints, reinterpret_cast<Point const *>(pPtAry));
+    m_pPrinterGfx->DrawPolygon (nPoints, reinterpret_cast<const Point *>(pPtAry));
 }
 
 void GenPspGraphics::drawPolyPolygon( sal_uInt32           nPoly,
@@ -532,7 +532,7 @@ public:
     explicit ImplPspFontData( const psp::FastPrintFontInfo& );
     virtual sal_IntPtr      GetFontId() const override { return mnFontId; }
     virtual PhysicalFontFace*   Clone() const override { return new ImplPspFontData( *this ); }
-    virtual LogicalFontInstance*  CreateFontInstance( FontSelectPattern& ) const override;
+    virtual LogicalFontInstance*  CreateFontInstance( const FontSelectPattern& ) const override;
 };
 
 ImplPspFontData::ImplPspFontData( const psp::FastPrintFontInfo& rInfo )
@@ -540,7 +540,7 @@ ImplPspFontData::ImplPspFontData( const psp::FastPrintFontInfo& rInfo )
     mnFontId( rInfo.m_nID )
 {}
 
-LogicalFontInstance* ImplPspFontData::CreateFontInstance( FontSelectPattern& rFSD ) const
+LogicalFontInstance* ImplPspFontData::CreateFontInstance( const FontSelectPattern& rFSD ) const
 {
     FreetypeFontInstance* pEntry = new FreetypeFontInstance( rFSD );
     return pEntry;
@@ -610,7 +610,7 @@ bool GenPspGraphics::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilitie
     return m_pFreetypeFont[0]->GetFontCapabilities(rFontCapabilities);
 }
 
-void GenPspGraphics::SetFont( FontSelectPattern *pEntry, int nFallbackLevel )
+void GenPspGraphics::SetFont( const FontSelectPattern *pEntry, int nFallbackLevel )
 {
     // release all fonts that are to be overridden
     for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i )
diff --git a/vcl/unx/kf5/KF5Font.hxx b/vcl/unx/kf5/KF5Font.hxx
deleted file mode 100644
index 7a00dafdf01c..000000000000
--- a/vcl/unx/kf5/KF5Font.hxx
+++ /dev/null
@@ -1,87 +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 .
- */
-
-#pragma once
-
-#include <vector>
-
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-
-#include <vcl/fontcapabilities.hxx>
-#include <vcl/metric.hxx>
-
-#include <salgdi.hxx>
-
-#include <unordered_map>
-
-class Kf5Frame;
-class FontAttributes;
-class CoreTextStyle;
-class XorEmulation;
-class CommonSalLayout;
-
-typedef sal_uInt32 sal_GlyphId;
-
-class CoreTextFontFace : public PhysicalFontFace
-{
-public:
-                                    CoreTextFontFace( const FontAttributes&, sal_IntPtr nFontID );
-    virtual                         ~CoreTextFontFace() override;
-
-    PhysicalFontFace*               Clone() const override;
-    LogicalFontInstance*            CreateFontInstance( FontSelectPattern& ) const override;
-    sal_IntPtr                      GetFontId() const override;
-
-    int                             GetFontTable( const char pTagName[5], unsigned char* ) const;
-
-    const FontCharMapRef            GetFontCharMap() const;
-    bool                            GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const;
-    bool                            HasChar( sal_uInt32 cChar ) const;
-
-protected:
-                                    CoreTextFontFace( const CoreTextFontFace& );
-
-private:
-    const sal_IntPtr                mnFontId;
-    mutable FontCharMapRef          mxCharMap;
-    mutable vcl::FontCapabilities   maFontCapabilities;
-    mutable bool                    mbFontCapabilitiesRead;
-};
-
-class SystemFontList
-{
-public:
-    SystemFontList( void );
-    ~SystemFontList( void );
-
-    bool        Init( void );
-    void        AddFont( CoreTextFontFace* );
-
-    void    AnnounceFonts( PhysicalFontCollection& ) const;
-    CoreTextFontFace* GetFontDataFromId( sal_IntPtr nFontId ) const;
-
-private:
-    CTFontCollectionRef mpCTFontCollection;
-    CFArrayRef mpCTFontArray;
-
-    typedef std::unordered_map<sal_IntPtr,CoreTextFontFace*> CTFontContainer;
-    CTFontContainer maFontContainer;
-};
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kf5/Kf5Bitmap.cxx b/vcl/unx/kf5/Kf5Bitmap.cxx
new file mode 100644
index 000000000000..e72750963b69
--- /dev/null
+++ b/vcl/unx/kf5/Kf5Bitmap.cxx
@@ -0,0 +1,197 @@
+/* -*- 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 Kf5Bitmap::(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 Kf5Bitmap::(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 "Kf5Bitmap.hxx"
+#include "Kf5Tools.hxx"
+#include "Kf5Graphics.hxx"
+
+#include <QtGui/QImage>
+#include <QtCore/QVector>
+#include <QtGui/QColor>
+
+Kf5Bitmap::Kf5Bitmap()
+{
+}
+
+Kf5Bitmap::Kf5Bitmap( const QImage &rImage )
+{
+    m_pImage.reset( new QImage( rImage ) );
+}
+
+Kf5Bitmap::~Kf5Bitmap()
+{
+}
+
+bool Kf5Bitmap::Create( const Size& rSize, sal_uInt16 nBitCount,
+                        const BitmapPalette& rPal )
+{
+    m_pImage.reset( new QImage( toQSize( rSize ), getBitFormat( nBitCount ) ) );
+    m_aPalette = rPal;
+    if( unsigned count = rPal.GetEntryCount() )
+    {
+        QVector<QRgb> aColorTable( count );
+        for ( unsigned i = 0; i < count; ++i )
+            aColorTable[ i ] = qRgb( rPal[ i ].GetRed(),
+                rPal[ i ].GetGreen(), rPal[ i ].GetBlue() );
+        m_pImage->setColorTable( aColorTable );
+    }
+    return true;
+}
+
+bool Kf5Bitmap::Create( const SalBitmap& rSalBmp )
+{
+    m_pImage.reset( new QImage(
+        *static_cast< const Kf5Bitmap*>( &rSalBmp )->m_pImage.get() ) );
+    return true;
+}
+
+bool Kf5Bitmap::Create( const SalBitmap& rSalBmp,
+                        SalGraphics* pSalGraphics )
+{
+    const Kf5Bitmap *pBitmap = static_cast< const Kf5Bitmap *>( &rSalBmp );
+    Kf5Graphics *pGraphics = static_cast< Kf5Graphics* >( pSalGraphics );
+    QImage *pImage = static_cast< QImage* >( pGraphics->m_pDevice );
+    m_pImage.reset( new QImage( pBitmap->m_pImage->convertToFormat( pImage->format() ) ) );
+    return true;
+}
+
+bool Kf5Bitmap::Create( const SalBitmap& rSalBmp,
+                        sal_uInt16 nNewBitCount )
+{
+    const Kf5Bitmap *pBitmap = static_cast< const Kf5Bitmap *>( &rSalBmp );
+    m_pImage.reset( new QImage( pBitmap->m_pImage->convertToFormat( getBitFormat( nNewBitCount ) ) ) );
+    return true;
+}
+
+bool Kf5Bitmap::Create( const css::uno::Reference< css::rendering::XBitmapCanvas >& rBitmapCanvas,
+                        Size& rSize, bool bMask )
+{
+    return false;
+}
+
+void Kf5Bitmap::Destroy()
+{
+    m_pImage.reset( nullptr );
+}
+
+Size Kf5Bitmap::GetSize() const
+{
+    return toSize( m_pImage->size() );
+}
+
+sal_uInt16 Kf5Bitmap::GetBitCount() const
+{
+    return getFormatBits( m_pImage->format() );
+}
+
+BitmapBuffer* Kf5Bitmap::AcquireBuffer( BitmapAccessMode nMode )
+{
+    if ( !m_pImage.get() )
+        return nullptr;
+
+    BitmapBuffer* pBuffer = new BitmapBuffer;
+    pBuffer->mnWidth = m_pImage->width();
+    pBuffer->mnHeight = m_pImage->height();
+    pBuffer->maPalette = m_aPalette;
+    pBuffer->mnScanlineSize = m_pImage->bytesPerLine();
+    pBuffer->mpBits = m_pImage->bits();
+    pBuffer->mnBitCount = getFormatBits( m_pImage->format() );
+
+    switch( pBuffer->mnBitCount )
+    {
+        case 1:
+            pBuffer->mnFormat = ScanlineFormat::N1BitMsbPal;
+            break;
+        case 4:
+            pBuffer->mnFormat = ScanlineFormat::N4BitMsnPal;
+            break;
+        case 8:
+            pBuffer->mnFormat = ScanlineFormat::N8BitPal;
+            break;
+#if 0
+        case 16:
+        {
+            pBuffer->mnFormat = ScanlineFormat::N16BitTcMsbMask;
+            ColorMaskElement aRedMask(k16BitRedColorMask);
+            aRedMask.CalcMaskShift();
+            ColorMaskElement aGreenMask(k16BitGreenColorMask);
+            aGreenMask.CalcMaskShift();
+            ColorMaskElement aBlueMask(k16BitBlueColorMask);
+            aBlueMask.CalcMaskShift();
+            pBuffer->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
+            break;
+        }
+#endif
+        case 24:
+            pBuffer->mnFormat = ScanlineFormat::N24BitTcBgr;
+            break;
+        case 32:
+        {
+            pBuffer->mnFormat = ScanlineFormat::N32BitTcArgb;
+#if 0
+            ColorMaskElement aRedMask(k32BitRedColorMask);
+            aRedMask.CalcMaskShift();
+            ColorMaskElement aGreenMask(k32BitGreenColorMask);
+            aGreenMask.CalcMaskShift();
+            ColorMaskElement aBlueMask(k32BitBlueColorMask);
+            aBlueMask.CalcMaskShift();
+            pBuffer->maColorMask  = ColorMask(aRedMask, aGreenMask, aBlueMask);
+#endif
+            break;
+        }
+    }
+
+#if 0
+    // some BitmapBuffer users depend on a complete palette
+    if( (pBuffer->mnBitCount <= 8) && !m_aPalette )
+        pBuffer->maPalette = GetDefaultPalette( pBuffer->mnBitCount, true );
+#endif
+    return pBuffer;
+}
+
+void Kf5Bitmap::ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode )
+{
+    // invalidate graphic context if we have different data
+    if( nMode == BitmapAccessMode::Write )
+        m_aPalette = pBuffer->maPalette;
+
+    delete pBuffer;
+}
+
+bool Kf5Bitmap::GetSystemData( BitmapSystemData& rData )
+{
+    return false;
+}
+
+bool Kf5Bitmap::ScalingSupported() const
+{
+    return false;
+}
+
+bool Kf5Bitmap::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag )
+{
+    return false;
+}
+
+bool Kf5Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol )
+{
+    return false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kf5/Kf5Bitmap.hxx b/vcl/unx/kf5/Kf5Bitmap.hxx
new file mode 100644
index 000000000000..07ac7f021c4f
--- /dev/null
+++ b/vcl/unx/kf5/Kf5Bitmap.hxx
@@ -0,0 +1,65 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <salbmp.hxx>
+
+#include <memory>
+
+class QImage;
+
+class VCL_DLLPUBLIC Kf5Bitmap : public SalBitmap
+{
+    std::unique_ptr< QImage > m_pImage;
+    BitmapPalette             m_aPalette;
+    bool                      m_bImageInUse;
+
+public:
+    Kf5Bitmap();
+    Kf5Bitmap( const QImage& rQImage );
+    virtual ~Kf5Bitmap() override;
+
+    const QImage*           GetQImage() const { return m_pImage.get(); }
+
+    virtual bool            Create( const Size& rSize,
+                                    sal_uInt16 nBitCount,
+                                    const BitmapPalette& rPal ) override;
+    virtual bool            Create( const SalBitmap& rSalBmp ) override;
+    virtual bool            Create( const SalBitmap& rSalBmp,
+                                    SalGraphics* pGraphics ) override;
+    virtual bool            Create( const SalBitmap& rSalBmp,
+                                    sal_uInt16 nNewBitCount ) override;
+    virtual bool            Create( const css::uno::Reference< css::rendering::XBitmapCanvas >& rBitmapCanvas,
+                                    Size& rSize,
+                                    bool bMask = false ) override;
+    virtual void            Destroy() final override;
+    virtual Size            GetSize() const override;
+    virtual sal_uInt16      GetBitCount() const override;
+
+    virtual BitmapBuffer*   AcquireBuffer( BitmapAccessMode nMode ) override;
+    virtual void            ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) override;
+    virtual bool            GetSystemData( BitmapSystemData& rData ) override;
+
+    virtual bool            ScalingSupported() const override;
+    virtual bool            Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) override;
+    virtual bool            Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kf5/Kf5Data.cxx b/vcl/unx/kf5/Kf5Data.cxx
index b7cdd785fe19..e1772ee0c0f8 100644
--- a/vcl/unx/kf5/Kf5Data.cxx
+++ b/vcl/unx/kf5/Kf5Data.cxx
@@ -31,7 +31,7 @@ Kf5Data::Kf5Data( SalInstance *pInstance )
     pSVData->maNWFData.mbDockingAreaSeparateTB = true;
     // no borders for menu, theming does that
     pSVData->maNWFData.mbFlatMenu = true;
-
+#if 0
     // Styled menus need additional space
     QStyle *style = QApplication::style();
     pSVData->maNWFData.mnMenuFormatBorderX =
@@ -40,6 +40,7 @@ Kf5Data::Kf5Data( SalInstance *pInstance )
     pSVData->maNWFData.mnMenuFormatBorderY =
        style->pixelMetric( QStyle::PM_MenuPanelWidth ) +
        style->pixelMetric( QStyle::PM_MenuVMargin );
+#endif
 }
 
 Kf5Data::~Kf5Data()
diff --git a/vcl/unx/kf5/Kf5Data.hxx b/vcl/unx/kf5/Kf5Data.hxx
index df0088b4c71c..863fb45c2ce1 100644
--- a/vcl/unx/kf5/Kf5Data.hxx
+++ b/vcl/unx/kf5/Kf5Data.hxx
@@ -19,7 +19,7 @@
 
 #pragma once
 
-#include <unx/saldata.hxx>
+#include <unx/gendata.hxx>
 
 class Kf5Data : public GenericUnixSalData
 {
diff --git a/vcl/unx/kf5/Kf5FontFace.cxx b/vcl/unx/kf5/Kf5FontFace.cxx
new file mode 100644
index 000000000000..b99e8591737e
--- /dev/null
+++ b/vcl/unx/kf5/Kf5FontFace.cxx
@@ -0,0 +1,128 @@
+/* -*- 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 "Kf5FontFace.hxx"
+#include "Kf5Tools.hxx"
+
+#include <sft.hxx>
+#include <impfontcharmap.hxx>
+#include <fontinstance.hxx>
+#include <fontselect.hxx>
+#include <PhysicalFontCollection.hxx>
+
+#include <QtGui/QFont>
+#include <QtGui/QRawFont>
+
+using namespace vcl;
+
+Kf5FontFace::Kf5FontFace( const Kf5FontFace& rSrc )
+  : PhysicalFontFace( rSrc )
+  , m_aFontId( rSrc.m_aFontId )
+{
+    if( rSrc.m_xCharMap.is() )
+        m_xCharMap = rSrc.m_xCharMap;
+}
+
+Kf5FontFace* Kf5FontFace::fromQFont( const QFont &rFont )
+{
+    FontAttributes aFA;
+    aFA.SetFamilyName( toOUString( rFont.family() ) );
+    aFA.SetStyleName( toOUString( rFont.styleName() ) );
+//    aFA.SetWeight( rFont.weight() );
+    aFA.SetItalic( rFont.italic() ? ITALIC_NORMAL : ITALIC_NONE );
+    // aFA.SetWidthType( rFont.stretch() );
+
+    return new Kf5FontFace( aFA, rFont.toString() ) ;
+}
+
+Kf5FontFace::Kf5FontFace( const FontAttributes& rFA, const QString &rFontID )
+    : PhysicalFontFace( rFA )
+    , m_aFontId( rFontID )
+    , m_bFontCapabilitiesRead( false )
+{
+}
+
+Kf5FontFace::~Kf5FontFace()
+{
+}
+
+sal_IntPtr Kf5FontFace::GetFontId() const
+{
+    return reinterpret_cast<sal_IntPtr>( &m_aFontId );
+}
+
+const FontCharMapRef Kf5FontFace::GetFontCharMap()
+{
+    if( m_xCharMap.is() )
+        return m_xCharMap;
+
+    QFont aFont;
+    aFont.fromString( m_aFontId );
+    QRawFont aRawFont( QRawFont::fromFont( aFont ) );
+    QByteArray aCMapTable = aRawFont.fontTable( "cmap" );
+    if ( aCMapTable.isEmpty() )
+    {
+        m_xCharMap = new FontCharMap();
+        return m_xCharMap;
+    }
+
+    CmapResult aCmapResult;
+    if( ParseCMAP( reinterpret_cast<const unsigned char*>( aCMapTable.data() ),
+                   aCMapTable.size(), aCmapResult ) )
+        m_xCharMap = new FontCharMap( aCmapResult );
+
+    return m_xCharMap;
+}
+
+bool Kf5FontFace::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities)
+{
+    // read this only once per font
+    if( m_bFontCapabilitiesRead )
+    {
+        rFontCapabilities = m_aFontCapabilities;
+        return rFontCapabilities.oUnicodeRange || rFontCapabilities.oCodePageRange;
+    }
+    m_bFontCapabilitiesRead = true;
+
+    QFont aFont;
+    aFont.fromString( m_aFontId );
+    QRawFont aRawFont( QRawFont::fromFont( aFont ) );
+    QByteArray aOS2Table = aRawFont.fontTable( "OS/2" );
+    if ( !aOS2Table.isEmpty() )
+    {
+        vcl::getTTCoverage( m_aFontCapabilities.oUnicodeRange,
+                            m_aFontCapabilities.oCodePageRange,
+                            reinterpret_cast<const unsigned char*>( aOS2Table.data() ),
+                            aOS2Table.size() );
+    }
+
+    rFontCapabilities = m_aFontCapabilities;
+    return rFontCapabilities.oUnicodeRange || rFontCapabilities.oCodePageRange;
+}
+
+PhysicalFontFace* Kf5FontFace::Clone() const
+{
+    return new Kf5FontFace( *this );
+}
+
+LogicalFontInstance* Kf5FontFace::CreateFontInstance( const FontSelectPattern& rFSD ) const
+{
+    return new LogicalFontInstance( rFSD );
+}
+
diff --git a/vcl/unx/kf5/Kf5FontFace.hxx b/vcl/unx/kf5/Kf5FontFace.hxx
new file mode 100644
index 000000000000..d2ae8099f345
--- /dev/null
+++ b/vcl/unx/kf5/Kf5FontFace.hxx
@@ -0,0 +1,62 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <PhysicalFontFace.hxx>
+
+#include <tools/ref.hxx>
+#include <vcl/fontcapabilities.hxx>
+#include <vcl/fontcharmap.hxx>
+
+#include <QtCore/QString>
+
+class FontAttributes;
+class FontSelectPattern;
+class QFont;
+
+class Kf5FontFace : public PhysicalFontFace
+{
+public:
+    virtual                  ~Kf5FontFace() override;
+
+    static Kf5FontFace*      fromQFont( const QFont &rFont );
+
+    PhysicalFontFace*        Clone() const override;
+    LogicalFontInstance*     CreateFontInstance( const FontSelectPattern& ) const override;
+    sal_IntPtr               GetFontId() const override;
+
+    int                      GetFontTable( const char pTagName[5], unsigned char* ) const;
+
+    const FontCharMapRef     GetFontCharMap();
+    bool                     GetFontCapabilities( vcl::FontCapabilities &rFontCapabilities );
+    bool                     HasChar( sal_uInt32 cChar ) const;
+
+protected:
+                             Kf5FontFace( const Kf5FontFace& );
+                             Kf5FontFace( const FontAttributes& rFA, const QString &rFontID );
+
+private:
+    const QString            m_aFontId;
+    FontCharMapRef           m_xCharMap;
+    vcl::FontCapabilities    m_aFontCapabilities;
+    bool                     m_bFontCapabilitiesRead;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kf5/Kf5Frame.cxx b/vcl/unx/kf5/Kf5Frame.cxx
index cf7e175e5d05..e008d2613fb1 100644
--- a/vcl/unx/kf5/Kf5Frame.cxx
+++ b/vcl/unx/kf5/Kf5Frame.cxx
@@ -19,36 +19,139 @@
 
 #include "Kf5Frame.hxx"
 
-Kf5Frame::Kf5Frame::Kf5Frame( Kf5Instance* pInstance,
-                 SalFrame* pParent,
-                 SalFrameStyleFlags nSalFrameStyle )
-{
+#include "Kf5Tools.hxx"
+#include "Kf5Instance.hxx"
+#include "Kf5Graphics.hxx"
+#include "Kf5Widget.hxx"
+
+#include <QtWidgets/QWidget>
+#include <QtGui/QRasterWindow>
+#include <QtGui/QBackingStore>
+#include <QtCore/QSize>
+#include <QtCore/QPoint>
+#include <QtGui/QIcon>
+
+#include <saldatabasic.hxx>
+#include <vcl/syswin.hxx>
+
+Kf5Frame::Kf5Frame( Kf5Frame* pParent, SalFrameStyleFlags nStyle )
+    : m_bGraphicsInUse( false )
+{
+    Kf5Instance *pInst = static_cast<Kf5Instance*>( GetSalData()->m_pInstance );
+    pInst->insertFrame( this );
+
+    if( nStyle & SalFrameStyleFlags::DEFAULT ) // ensure default style
+    {
+        nStyle |= SalFrameStyleFlags::MOVEABLE | SalFrameStyleFlags::SIZEABLE | SalFrameStyleFlags::CLOSEABLE;
+        nStyle &= ~SalFrameStyleFlags::FLOAT;
+    }
+
+    m_nStyle = nStyle;
+    m_pParent = pParent;
+
+    Qt::WindowFlags aWinFlags;
+    if ( !(nStyle & SalFrameStyleFlags::SYSTEMCHILD) )
+    {
+        if( nStyle & SalFrameStyleFlags::INTRO )
+            aWinFlags |= Qt::SplashScreen;
+        if( (nStyle & SalFrameStyleFlags::FLOAT) &&
+                ! (nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION) )
+            aWinFlags |= Qt::Popup;
+        else if( nStyle & SalFrameStyleFlags::DIALOG && pParent )
+            aWinFlags |= Qt::Dialog;
+        else if( nStyle & SalFrameStyleFlags::TOOLWINDOW )
+            aWinFlags |= Qt::Tool;
+        else if( (nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION) )
+            aWinFlags |= Qt::Window | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus;
+        else
+            aWinFlags |= Qt::Window;
+    }
+
+    m_pQWidget.reset( new Kf5Widget( *this, pParent ? pParent->GetQWidget() : nullptr, aWinFlags ) );
+
+    if (pParent && !(pParent->m_nStyle & SalFrameStyleFlags::PLUG))
+        m_pQWidget->windowHandle()->setTransientParent( pParent->GetQWidget()->window()->windowHandle() );
 }
 
 Kf5Frame::~Kf5Frame()
 {
+    Kf5Instance *pInst = static_cast<Kf5Instance*>( GetSalData()->m_pInstance );
+    pInst->eraseFrame( this );
 }
 
-SalGraphics* Kf5Frame::AcquireGraphics()
+QPaintDevice* Kf5Frame::GetQPaintDevice() const
 {
+    QWidget *window = m_pQWidget->window();
+    if ( window->windowHandle() )
+        return dynamic_cast< QPaintDevice* >( window->windowHandle() );
+    return nullptr;
 }
 
-void Kf5Frame::ReleaseGraphics( SalGraphics* pGraphics )
+void Kf5Frame::TriggerPaintEvent()
+{
+    QSize aSize( m_pQWidget->size() );
+    SalPaintEvent aPaintEvt(0, 0, aSize.width(), aSize.height(), true);
+    CallCallback(SalEvent::Paint, &aPaintEvt);
+    m_pQWidget->update();
+}
+
+SalGraphics* Kf5Frame::AcquireGraphics()
 {
+    if( m_bGraphicsInUse )
+        return nullptr;
+
+    if( !m_pGraphics.get() )
+    {
+        m_pGraphics.reset( new Kf5Graphics( this ) );
+        m_pQImage.reset( new QImage( m_pQWidget->size(), QImage::Format_ARGB32 ) );
+        m_pGraphics->ChangePaintDevice( m_pQImage.get() );
+        TriggerPaintEvent();
+    }
+    m_bGraphicsInUse = true;
+
+    return m_pGraphics.get();
 }
 
+void Kf5Frame::ReleaseGraphics( SalGraphics* pSalGraph )
+{
+    (void) pSalGraph;
+    assert( pSalGraph == m_pGraphics.get() );
+    m_bGraphicsInUse = false;
+}
 
-bool Kf5Frame::PostEvent(ImplSVEvent* pData)
+bool Kf5Frame::PostEvent( ImplSVEvent* pData )
 {
-    return false;
+    Kf5Instance *pInst = static_cast<Kf5Instance*>( GetSalData()->m_pInstance );
+    pInst->PostEvent( this, pData, SalEvent::UserEvent );
+    return true;
 }
 
 void Kf5Frame::SetTitle( const OUString& rTitle )
 {
+    m_pQWidget->window()->setWindowTitle( toQString( rTitle ) );
 }
 
 void Kf5Frame::SetIcon( sal_uInt16 nIcon )
 {
+    const char * appicon;
+
+    if (nIcon == SV_ICON_ID_TEXT)
+        appicon = "libreoffice-writer";
+    else if (nIcon == SV_ICON_ID_SPREADSHEET)
+        appicon = "libreoffice-calc";
+    else if (nIcon == SV_ICON_ID_DRAWING)
+        appicon = "libreoffice-draw";
+    else if (nIcon == SV_ICON_ID_PRESENTATION)
+        appicon = "libreoffice-impress";
+    else if (nIcon == SV_ICON_ID_DATABASE)
+        appicon = "libreoffice-base";
+    else if (nIcon == SV_ICON_ID_FORMULA)
+        appicon = "libreoffice-math";
+    else
+        appicon = "libreoffice-startcenter";
+
+    QIcon aIcon = QIcon::fromTheme( appicon );
+    m_pQWidget->window()->setWindowIcon( aIcon );
 }
 
 void Kf5Frame::SetMenu( SalMenu* pMenu )
@@ -65,14 +168,20 @@ void Kf5Frame::SetExtendedFrameStyle( SalExtStyle nExtStyle )
 
 void Kf5Frame::Show( bool bVisible, bool bNoActivate )
 {
+    assert( m_pQWidget.get() );
+    m_pQWidget->setVisible( bVisible );
 }
 
 void Kf5Frame::SetMinClientSize( long nWidth, long nHeight )
 {
+    if( ! isChild() )
+        m_pQWidget->setMinimumSize( nWidth, nHeight );
 }
 
 void Kf5Frame::SetMaxClientSize( long nWidth, long nHeight )
 {
+    if( ! isChild() )
+        m_pQWidget->setMaximumSize( nWidth, nHeight );
 }
 
 void Kf5Frame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags )
@@ -81,6 +190,8 @@ void Kf5Frame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt
 
 void Kf5Frame::GetClientSize( long& rWidth, long& rHeight )
 {
+    rWidth = m_pQWidget->width();
+    rHeight = m_pQWidget->height();
 }
 
 void Kf5Frame::GetWorkArea( tools::Rectangle& rRect )
@@ -89,14 +200,94 @@ void Kf5Frame::GetWorkArea( tools::Rectangle& rRect )
 
 SalFrame* Kf5Frame::GetParent() const
 {
+    return m_pParent;
 }
 
 void Kf5Frame::SetWindowState( const SalFrameState* pState )
 {
+    if( !m_pQWidget->isWindow() || ! pState || isChild( true, false ) )
+        return;
+
+    const WindowStateMask nMaxGeometryMask =
+        WindowStateMask::X | WindowStateMask::Y |
+        WindowStateMask::Width | WindowStateMask::Height |
+        WindowStateMask::MaximizedX | WindowStateMask::MaximizedY |
+        WindowStateMask::MaximizedWidth | WindowStateMask::MaximizedHeight;
+
+    if( (pState->mnMask & WindowStateMask::State) &&
+            (pState->mnState & WindowStateState::Maximized) &&
+            (pState->mnMask & nMaxGeometryMask) == nMaxGeometryMask )
+        m_pQWidget->showMaximized();
+    else if( pState->mnMask & (WindowStateMask::X | WindowStateMask::Y |
+                               WindowStateMask::Width | WindowStateMask::Height ) )
+    {
+        QRect rect = m_pQWidget->geometry();
+        if ( pState->mnMask & WindowStateMask::X )
+            rect.setX( pState->mnX );
+        if ( pState->mnMask & WindowStateMask::Y )
+            rect.setY( pState->mnY );
+        if ( pState->mnMask & WindowStateMask::Width )
+            rect.setWidth( pState->mnWidth );
+        if ( pState->mnMask & WindowStateMask::Height )
+            rect.setHeight( pState->mnHeight );
+        m_pQWidget->setGeometry( rect );
+    }
+    else if( pState->mnMask & WindowStateMask::State && ! isChild() )
+    {
+        if( (pState->mnState & WindowStateState::Minimized) && m_pQWidget->isWindow() )
+            m_pQWidget->showMinimized();
+        else
+            m_pQWidget->showNormal();
+    }
 }
 
 bool Kf5Frame::GetWindowState( SalFrameState* pState )
 {
+    pState->mnState = WindowStateState::Normal;
+    pState->mnMask  = WindowStateMask::State;
+    if( m_pQWidget->isMinimized() || !m_pQWidget->windowHandle() )
+        pState->mnState |= WindowStateState::Minimized;
+    else if( m_pQWidget->isMaximized() )
+    {
+        pState->mnState |= WindowStateState::Maximized;
+#if 0
+        pState->mnX                 = m_aRestorePosSize.Left();
+        pState->mnY                 = m_aRestorePosSize.Top();
+        pState->mnWidth             = m_aRestorePosSize.GetWidth();
+        pState->mnHeight            = m_aRestorePosSize.GetHeight();
+        pState->mnMask  |= WindowStateMask::MaximizedX          |
+                           WindowStateMask::MaximizedY          |
+                           WindowStateMask::MaximizedWidth      |
+                           WindowStateMask::MaximizedHeight;
+#endif
+    }
+    else
+    {
+        if ( m_pQWidget->windowHandle() )
+        {
+            QPoint pos = m_pQWidget->windowHandle()->position();
+            QSize size = m_pQWidget->windowHandle()->size();
+            pState->mnX = pos.x();
+            pState->mnY = pos.y();
+            pState->mnWidth = size.width();
+            pState->mnHeight = size.height();
+        }
+        else
+        {
+            QRect rect = m_pQWidget->geometry();
+            pState->mnX = rect.x();
+            pState->mnY = rect.y();
+            pState->mnWidth = rect.width();
+            pState->mnHeight = rect.height();
+        }
+        pState->mnMask  |= WindowStateMask::X            |
+                           WindowStateMask::Y            |
+                           WindowStateMask::Width        |
+                           WindowStateMask::Height;
+    }
+
+    TriggerPaintEvent();
+    return true;
 }
 
 void Kf5Frame::ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay )
@@ -129,10 +320,12 @@ void Kf5Frame::SetPointerPos( long nX, long nY )
 
 void Kf5Frame::Flush()
 {
+    TriggerPaintEvent();
 }
 
 void Kf5Frame::Flush( const tools::Rectangle& rRect )
 {
+    TriggerPaintEvent();
 }
 
 void Kf5Frame::SetInputContext( SalInputContext* pContext )
@@ -185,6 +378,7 @@ void Kf5Frame::SimulateKeyPress( sal_uInt16 nKeyCode )
 
 void Kf5Frame::SetParent( SalFrame* pNewParent )
 {
+    m_pParent = static_cast< Kf5Frame* >( pNewParent );
 }
 
 bool Kf5Frame::SetPluginParent( SystemParentData* pNewParent )
diff --git a/vcl/unx/kf5/Kf5Frame.hxx b/vcl/unx/kf5/Kf5Frame.hxx
index d08040b23c71..cbbea1ddf3b7 100644
--- a/vcl/unx/kf5/Kf5Frame.hxx
+++ b/vcl/unx/kf5/Kf5Frame.hxx
@@ -21,16 +21,47 @@
 
 #include <salframe.hxx>
 
+#include <memory>
+
+class Kf5Graphics;
 class Kf5Instance;
+class Kf5Widget;
+class QWidget;
+class QPaintDevice;
+class QImage;
 
-class VCL_DLLPUBLIC Kf5Frame : public SalFrame
+class Kf5Frame
+    : public SalFrame
 {
+    friend class Kf5Widget;
+
+    std::unique_ptr< QWidget >      m_pQWidget;
+    std::unique_ptr< QImage >       m_pQImage;
+    std::unique_ptr< Kf5Graphics >  m_pGraphics;
+    bool                            m_bGraphicsInUse;
+    SalFrameStyleFlags              m_nStyle;
+    Kf5Frame                       *m_pParent;
+
+    bool isChild( bool bPlug = true, bool bSysChild = true )
+    {
+        SalFrameStyleFlags nMask = SalFrameStyleFlags::NONE;
+        if( bPlug )
+            nMask |= SalFrameStyleFlags::PLUG;
+        if( bSysChild )
+            nMask |= SalFrameStyleFlags::SYSTEMCHILD;
+        return bool(m_nStyle & nMask);
+    }
+
+    void TriggerPaintEvent();
+
 public:
-    Kf5Frame( Kf5Instance* pInstance,
-              SalFrame* pParent,
+    Kf5Frame( Kf5Frame* pParent,
               SalFrameStyleFlags nSalFrameStyle );
     virtual ~Kf5Frame() override;
 
+    QWidget* GetQWidget() const { return m_pQWidget.get(); }
+    QPaintDevice* GetQPaintDevice() const;
+
     virtual SalGraphics*        AcquireGraphics() override;
     virtual void                ReleaseGraphics( SalGraphics* pGraphics ) override;
 
diff --git a/vcl/unx/kf5/Kf5Graphics.cxx b/vcl/unx/kf5/Kf5Graphics.cxx
index 836504b87441..e822e8213d71 100644
--- a/vcl/unx/kf5/Kf5Graphics.cxx
+++ b/vcl/unx/kf5/Kf5Graphics.cxx
@@ -18,8 +18,22 @@
  */
 
 #include "Kf5Graphics.hxx"
+#include "Kf5Frame.hxx"
 
-Kf5Graphics::Kf5Graphics()
+#include <QtWidgets/QWidget>
+#include <QtGui/QRasterWindow>
+
+#include <QtGui/QPainter>
+
+Kf5Graphics::Kf5Graphics( Kf5Frame *pFrame )
+    : m_pFrame( pFrame )
+    , m_pDevice( nullptr )
+{
+}
+
+Kf5Graphics::Kf5Graphics( QPaintDevice *pDevice )
+    : m_pFrame( nullptr )
+    , m_pDevice( pDevice )
 {
 }
 
@@ -27,6 +41,27 @@ Kf5Graphics::~Kf5Graphics()
 {
 }
 
+void Kf5Graphics::PreparePainter()
+{
+    if ( m_pPainter.get() )
+        return;
+    if ( m_pDevice )
+        m_pPainter.reset( new QPainter( m_pDevice ) );
+    else
+    {
+        assert( dynamic_cast< QPaintDevice* >( m_pFrame->GetQWidget() ) );
+        m_pPainter.reset( new QPainter( m_pFrame->GetQWidget() ) );
+    }
+    if (!m_aClipRegion.isEmpty())
+        m_pPainter->setClipRegion( m_aClipRegion );
+}
+
+void Kf5Graphics::ChangePaintDevice( QPaintDevice *pDevice )
+{
+    m_pPainter.reset( nullptr );
+    m_pDevice = pDevice;
+}
+
 SalGraphicsImpl* Kf5Graphics::GetImpl() const
 {
     return nullptr;
@@ -42,4 +77,38 @@ bool Kf5Graphics::supportsOperation( OutDevSupportType ) const
     return false;
 }
 
+#if ENABLE_CAIRO_CANVAS
+
+bool Kf5Graphics::SupportsCairo() const
+{
+    return false;
+}
+
+cairo::SurfaceSharedPtr Kf5Graphics::CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const
+{
+    return nullptr;
+}
+
+cairo::SurfaceSharedPtr Kf5Graphics::CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const
+{
+    return nullptr;
+}
+
+cairo::SurfaceSharedPtr Kf5Graphics::CreateBitmapSurface(const OutputDevice& rRefDevice, const BitmapSystemData& rData, const Size& rSize) const
+{
+    return nullptr;
+}
+
+css::uno::Any Kf5Graphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const
+{
+    return css::uno::Any();
+}
+
+SystemFontData Kf5Graphics::GetSysFontData( int nFallbacklevel ) const
+{
+    return SystemFontData();
+}
+
+#endif
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kf5/Kf5Graphics.hxx b/vcl/unx/kf5/Kf5Graphics.hxx
index 2fa1398bd6ef..3f5af1a80bda 100644
--- a/vcl/unx/kf5/Kf5Graphics.hxx
+++ b/vcl/unx/kf5/Kf5Graphics.hxx
@@ -19,34 +19,59 @@
 
 #pragma once
 
-#include <vector>
-
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-
-#include <vcl/fontcapabilities.hxx>
-#include <vcl/metric.hxx>
-
 #include <salgdi.hxx>
 
-#include <unordered_map>
+#include <memory>
+
+#include <QtGui/QRegion>
 
-class Kf5Frame;
-class FontAttributes;
-class XorEmulation;
 class CommonSalLayout;
+class Kf5Bitmap;
+class Kf5Frame;
+class PhysicalFontCollection;
+class PhysicalFontFace;
+class QImage;
+class QPaintDevice;
+class QPainter;
 
 class Kf5Graphics : public SalGraphics
 {
-    Kf5Frame*               mpFrame;
+    friend class Kf5Bitmap;
+
+    Kf5Frame                     *m_pFrame;
+    QPaintDevice                 *m_pDevice;
+    QRegion                       m_aClipRegion;
+    std::unique_ptr< QPainter >   m_pPainter;
+    bool                          m_bIsQImage;
+    PhysicalFontCollection       *m_pFontCollection;
+    PhysicalFontFace             *m_pFont;
+
+    void PreparePainter();
 
 public:
-                            Kf5Graphics();
-    virtual                 ~Kf5Graphics() override;
+    Kf5Graphics( Kf5Frame *pFrame );
+    Kf5Graphics( QPaintDevice *pDevice );
+    virtual ~Kf5Graphics() override;
+
+    void ChangePaintDevice( QPaintDevice *pDevice );
 
     virtual SalGraphicsImpl* GetImpl() const override;
-    virtual SystemGraphicsData
-                            GetGraphicsData() const override;
-    virtual bool            supportsOperation( OutDevSupportType ) const override;
+    virtual SystemGraphicsData GetGraphicsData() const override;
+    virtual bool supportsOperation( OutDevSupportType ) const override;
+
+#if ENABLE_CAIRO_CANVAS
+    virtual bool                     SupportsCairo() const override;
+    virtual cairo::SurfaceSharedPtr  CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const override;
+    virtual cairo::SurfaceSharedPtr  CreateSurface(const OutputDevice& rRefDevice,
+                                                   int x, int y, int width, int height) const override;
+    virtual cairo::SurfaceSharedPtr  CreateBitmapSurface(const OutputDevice& rRefDevice,
+                                                         const BitmapSystemData& rData, const Size& rSize) const override;
+    virtual css::uno::Any            GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface,
+                                                            const basegfx::B2ISize& rSize) const override;
+    virtual SystemFontData           GetSysFontData( int nFallbacklevel ) const override;
+#endif // ENABLE_CAIRO_CANVAS
+
+    // GDI
 
     virtual bool            setClipRegion( const vcl::Region& ) override;
     virtual void            ResetClipRegion() override;
@@ -55,7 +80,7 @@ public:
     virtual void            drawPixel( long nX, long nY, SalColor nSalColor ) override;
     virtual void            drawLine( long nX1, long nY1, long nX2, long nY2 ) override;
     virtual void            drawRect( long nX, long nY, long nWidth, long nHeight ) override;
-    virtual void            drawPolyLine( sal_uInt32 nPoints, SalPoint* pPtAry ) override;
+    virtual void            drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry ) override;
     virtual void            drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ) override;
     virtual void            drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, PCONSTSALPOINT* pPtAry ) override;
     virtual bool            drawPolyPolygon( const basegfx::B2DPolyPolygon&, double fTransparency ) override;
@@ -128,7 +153,7 @@ public:
     // Text rendering + font support
 
     virtual void            SetTextColor( SalColor nSalColor ) override;
-    virtual void            SetFont( FontSelectPattern*, int nFallbackLevel ) override;
+    virtual void            SetFont( const FontSelectPattern*, int nFallbackLevel ) override;
     virtual void            GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
     virtual const FontCharMapRef GetFontCharMap() const override;
     virtual bool            GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override;
diff --git a/vcl/unx/kf5/Kf5Graphics_GDI.cxx b/vcl/unx/kf5/Kf5Graphics_GDI.cxx
index 8a73f48acf74..7a6d62341acc 100644
--- a/vcl/unx/kf5/Kf5Graphics_GDI.cxx
+++ b/vcl/unx/kf5/Kf5Graphics_GDI.cxx
@@ -19,41 +19,96 @@
 
 #include "Kf5Graphics.hxx"
 
-bool Kf5Graphics::setClipRegion( const vcl::Region& )
-{
-    return false;
+#include "Kf5Tools.hxx"
+#include "Kf5Frame.hxx"
+#include "Kf5Bitmap.hxx"
+
+#include <QtGui/QColor>
+#include <QtGui/QPainter>
+#include <QtGui/QRegion>
+#include <QtGui/QScreen>
+#include <QtGui/QWindow>
+#include <QtWidgets/QWidget>
+
+bool Kf5Graphics::setClipRegion( const vcl::Region& rRegion )
+{
+    PreparePainter();
+    if ( rRegion.IsRectangle() )
+        m_aClipRegion = toQRect( rRegion.GetBoundRect() );
+    else if( !rRegion.HasPolyPolygonOrB2DPolyPolygon() )
+    {
+        QRegion aQRegion;
+        RectangleVector aRectangles;
+        rRegion.GetRegionRectangles( aRectangles );
+        for ( auto & rRect : aRectangles )
+            aQRegion += toQRect( rRect );
+        m_aClipRegion = aQRegion;
+    }
+    else
+    {
+        QPolygon aPolygon;
+        assert( !"impl" );
+// TODO
+    }
+    m_pPainter->setClipRegion( m_aClipRegion );
+    return true;
 }
 
 void Kf5Graphics::ResetClipRegion()
 {
+    m_aClipRegion = QRegion( static_cast<QImage*>( m_pDevice )->rect() );
+    PreparePainter();
 }
 
 void Kf5Graphics::drawPixel( long nX, long nY )
 {
+    PreparePainter();
+    m_pPainter->drawPoint( nX, nY );
 }
 
 void Kf5Graphics::drawPixel( long nX, long nY, SalColor nSalColor )
 {
+    PreparePainter();
+    m_pPainter->setPen( QColor( QRgb( nSalColor )  ) );
+    m_pPainter->drawPoint( nX, nY );
 }
 
 void Kf5Graphics::drawLine( long nX1, long nY1, long nX2, long nY2 )
 {
+    PreparePainter();
+    m_pPainter->drawLine( nX1, nY1, nX2, nY2 );
 }
 
 void Kf5Graphics::drawRect( long nX, long nY, long nWidth, long nHeight )
 {
+    PreparePainter();
+    m_pPainter->drawRect( nX, nY, nWidth, nHeight );
 }
 
-void Kf5Graphics::drawPolyLine( sal_uInt32 nPoints, SalPoint* pPtAry )
+void Kf5Graphics::drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry )
 {
+    PreparePainter();
+    QPoint *pPoints = new QPoint[ nPoints ];
+    for ( sal_uInt32 i = 0; i < nPoints; ++i, ++pPtAry )
+        pPoints[ i ] = QPoint( pPtAry->mnX, pPtAry->mnY );
+    m_pPainter->drawPolyline( pPoints, nPoints );
+    delete [] pPoints;
 }
 
 void Kf5Graphics::drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry )
 {
+    PreparePainter();
+    QPoint *pPoints = new QPoint[ nPoints ];
+    for ( sal_uInt32 i = 0; i < nPoints; ++i, ++pPtAry )
+        pPoints[ i ] = QPoint( pPtAry->mnX, pPtAry->mnY );
+    m_pPainter->drawPolygon( pPoints, nPoints );
+    delete [] pPoints;
 }
 
 void Kf5Graphics::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, PCONSTSALPOINT* pPtAry )
 {
+    if( 0 == nPoly )
+        return;
 }
 
 bool Kf5Graphics::drawPolyPolygon( const basegfx::B2DPolyPolygon&, double fTransparency )
@@ -77,13 +132,12 @@ bool Kf5Graphics::drawPolyPolygonBezier( sal_uInt32 nPoly, const sal_uInt32* pPo
     return false;
 }
 
-bool Kf5Graphics::drawPolyLine(
-                                const basegfx::B2DPolygon&,
+bool Kf5Graphics::drawPolyLine( const basegfx::B2DPolygon&,
                                 double fTransparency,
                                 const basegfx::B2DVector& rLineWidths,
                                 basegfx::B2DLineJoin,
                                 css::drawing::LineCap eLineCap,
-                                double fMiterMinimumAngle)
+                                double fMiterMinimumAngle )
 {
     return false;
 }
@@ -96,34 +150,75 @@ bool Kf5Graphics::drawGradient( const tools::PolyPolygon&, const Gradient& )
 void Kf5Graphics::copyArea( long nDestX, long nDestY, long nSrcX, long nSrcY, long nSrcWidth,

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list