diff -urN libreoffice-5.4.2.2-orig/Repository.mk libreoffice-5.4.2.2/Repository.mk
--- libreoffice-5.4.2.2-orig/Repository.mk	2017-09-28 03:03:26 +0900
+++ libreoffice-5.4.2.2/Repository.mk	2017-11-08 19:04:25 +0900
@@ -244,7 +244,7 @@
 	scd \
 	scfilt \
 	scui \
-	wpftcalc \
+	$(if $(filter YES,$(BUILD_OLD_DOC_FILTERS)),wpftcalc) \
 	$(if $(ENABLE_COINMP)$(ENABLE_LPSOLVE),solver) \
 	$(call gb_Helper_optional,SCRIPTING,vbaobj) \
 ))
@@ -252,7 +252,7 @@
 $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,graphicfilter, \
 	svgfilter \
 	flash \
-	wpftdraw \
+	$(if $(filter YES,$(BUILD_OLD_DOC_FILTERS)),wpftdraw) \
 	graphicfilter \
 ))
 
@@ -271,7 +271,7 @@
 	animcore \
 	PresenterScreen \
 	PresentationMinimizer \
-	wpftimpress \
+	$(if $(filter YES,$(BUILD_OLD_DOC_FILTERS)),wpftimpress) \
 ))
 
 $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,onlineupdate, \
@@ -446,7 +446,7 @@
 	$(if $(USING_X11), \
 		vclplug_gen \
 	) \
-	writerperfect \
+	$(if $(filter YES,$(BUILD_OLD_DOC_FILTERS)),writerperfect) \
 	xmlscript \
 	xmlfa \
 	xmlfd \
@@ -510,7 +510,7 @@
 	swui \
 	t602filter \
 	$(call gb_Helper_optional,SCRIPTING,vbaswobj) \
-	wpftwriter \
+	$(if $(filter YES,$(BUILD_OLD_DOC_FILTERS)),wpftwriter) \
 	writerfilter \
 ))
 
@@ -1101,7 +1101,7 @@
 	upd \
 	uui \
 	vcl \
-	writerperfect \
+	$(if $(filter YES,$(BUILD_OLD_DOC_FILTERS)),writerperfect) \
 	$(if $(ENABLE_NSS),xmlsec) \
 	xsltdlg \
 ))
@@ -1148,7 +1148,7 @@
 	svx \
 	uui \
 	vcl \
-	writerperfect \
+	$(if $(filter YES,$(BUILD_OLD_DOC_FILTERS)),writerperfect) \
 	$(if $(ENABLE_NSS),xmlsec) \
 ))
 
diff -urN libreoffice-5.4.2.2-orig/RepositoryExternal.mk libreoffice-5.4.2.2/RepositoryExternal.mk
--- libreoffice-5.4.2.2-orig/RepositoryExternal.mk	2017-09-28 03:03:26 +0900
+++ libreoffice-5.4.2.2/RepositoryExternal.mk	2017-11-08 19:02:49 +0900
@@ -1585,6 +1585,7 @@
 endif # DISABLE_OPENSSL
 
 
+ifeq ($(BUILD_OLD_DOC_FILTERS),YES)
 ifneq ($(SYSTEM_CDR),)
 
 define gb_LinkTarget__use_cdr
@@ -1610,6 +1611,7 @@
 endef
 
 endif # SYSTEM_CDR
+endif # BUILD_OLD_DOC_FILTERS
 
 
 ifneq ($(SYSTEM_EBOOK),)
@@ -1647,6 +1649,7 @@
 endif # SYSTEM_EBOOK
 
 
+ifeq ($(BUILD_OLD_DOC_FILTERS),YES)
 ifneq ($(SYSTEM_ETONYEK),)
 
 define gb_LinkTarget__use_etonyek
@@ -1708,8 +1711,10 @@
 endif
 
 endif # SYSTEM_ETONYEK
+endif # BUILD_OLD_DOC_FILTER
 
 
+ifeq ($(BUILD_OLD_DOC_FILTERS),YES)
 ifneq ($(SYSTEM_FREEHAND),)
 
 define gb_LinkTarget__use_freehand
@@ -1743,8 +1748,10 @@
 endef
 
 endif # SYSTEM_FREEHAND
+endif # BUILD_OLD_DOC_FILTERS
 
 
+ifeq ($(BUILD_OLD_DOC_FILTERS),YES)
 ifneq ($(SYSTEM_ODFGEN),)
 
 define gb_LinkTarget__use_odfgen
@@ -1798,6 +1805,7 @@
 endif
 
 endif # SYSTEM_ODFGEN
+endif # BUILD_OLD_DOC_FILTERS
 
 
 ifneq ($(SYSTEM_REVENGE),)
@@ -1866,6 +1874,7 @@
 endif # SYSTEM_REVENGE
 
 
+ifeq ($(BUILD_OLD_DOC_FILTERS),YES)
 ifneq ($(SYSTEM_ABW),)
 
 define gb_LinkTarget__use_abw
@@ -1897,8 +1906,10 @@
 endef
 
 endif # SYSTEM_ABW
+endif # BUILD_OLD_DOC_FILTERS
 
 
+ifeq ($(BUILD_OLD_DOC_FILTERS),YES)
 ifneq ($(SYSTEM_MSPUB),)
 
 define gb_LinkTarget__use_mspub
@@ -1925,8 +1936,10 @@
 endef
 
 endif # SYSTEM_MSPUB
+endif # BUILD_OLD_DOC_FILTERS
 
 
+ifeq ($(BUILD_OLD_DOC_FILTERS),YES)
 ifneq ($(SYSTEM_PAGEMAKER),)
 
 define gb_LinkTarget__use_pagemaker
@@ -1958,6 +1971,7 @@
 endef
 
 endif # SYSTEM_PAGEMAKER
+endif # BUILD_OLD_DOC_FILTERS
 
 
 ifneq ($(SYSTEM_ZMF),)
@@ -1993,6 +2007,7 @@
 endif # SYSTEM_ZMF
 
 
+ifeq ($(BUILD_OLD_DOC_FILTERS),YES)
 ifneq ($(SYSTEM_VISIO),)
 
 define gb_LinkTarget__use_visio
@@ -2019,8 +2034,10 @@
 endef
 
 endif # SYSTEM_VISIO
+endif # BUILD_OLD_DOC_FILTERS
 
 
+ifeq ($(BUILD_OLD_DOC_FILTERS),YES)
 ifneq ($(SYSTEM_WPD),)
 
 define gb_LinkTarget__use_wpd
@@ -2084,8 +2101,10 @@
 endif # MSC
 
 endif # SYSTEM_WPD
+endif # BUILD_OLD_DOC_FILTERS
 
 
+ifeq ($(BUILD_OLD_DOC_FILTERS),YES)
 ifneq ($(SYSTEM_WPG),)
 
 define gb_LinkTarget__use_wpg
@@ -2139,8 +2158,10 @@
 endif # MSC
 
 endif # SYSTEM_WPG
+endif # BUILD_OLD_DOC_FILTERS
 
 
+ifeq ($(BUILD_OLD_DOC_FILTERS),YES)
 ifneq ($(SYSTEM_WPS),)
 
 define gb_LinkTarget__use_wps
@@ -2195,8 +2216,10 @@
 endif # MSC
 
 endif # SYSTEM_WPS
+endif # BUILD_OLD_DOC_FILTERS
 
 
+ifeq ($(BUILD_OLD_DOC_FILTERS),YES)
 ifneq ($(SYSTEM_MWAW),)
 
 define gb_LinkTarget__use_mwaw
@@ -2250,7 +2273,9 @@
 endif # MSC
 
 endif # SYSTEM_MWAW
+endif # BUILD_OLD_DOC_FILTERS
 
+ifeq ($(BUILD_OLD_DOC_FILTERS),YES)
 ifneq ($(SYSTEM_STAROFFICE),)
 
 define gb_LinkTarget__use_staroffice
@@ -2304,6 +2329,7 @@
 endif # MSC
 
 endif # SYSTEM_STAROFFICE
+endif # BUILD_OLD_DOC_FILTERS
 
 
 ifneq ($(SYSTEM_LCMS2),)
diff -urN libreoffice-5.4.2.2-orig/config_host.mk.in libreoffice-5.4.2.2/config_host.mk.in
--- libreoffice-5.4.2.2-orig/config_host.mk.in	2017-09-28 03:03:26 +0900
+++ libreoffice-5.4.2.2/config_host.mk.in	2017-11-08 19:02:49 +0900
@@ -49,6 +49,7 @@
 export BUILD_TYPE=@BUILD_TYPE@
 export BUILD_UNOWINREG=@BUILD_UNOWINREG@
 export BUILD_VER_STRING=@BUILD_VER_STRING@
+export BUILD_OLD_DOC_FILTERS=@BUILD_OLD_DOC_FILTERS@
 export BUILD_X64=@BUILD_X64@
 export BZIP2_CFLAGS=$(gb_SPACE)@BZIP2_CFLAGS@
 export BZIP2_LIBS=$(gb_SPACE)@BZIP2_LIBS@
diff -urN libreoffice-5.4.2.2-orig/configure.ac libreoffice-5.4.2.2/configure.ac
--- libreoffice-5.4.2.2-orig/configure.ac	2017-09-28 03:03:26 +0900
+++ libreoffice-5.4.2.2/configure.ac	2017-11-08 19:07:35 +0900
@@ -1676,6 +1676,11 @@
         [Specify external thesaurus dir.]),
 ,)
 
+AC_ARG_ENABLE(old-doc-filters,
+    AS_HELP_STRING([--disable-old-doc-filters],
+        [Don't include import/export filters for old document formats.]),,
+    [enable_old_doc_filters=yes])
+
 AC_ARG_WITH(system-zlib,
     AS_HELP_STRING([--with-system-zlib],
         [Use zlib already on system.]),,
@@ -7431,6 +7436,7 @@
     enable_postgresql_sdbc=no
     enable_extension_integration=no
     enable_report_builder=no
+    enable_old_doc_filters=no
     with_theme="tango"
     with_ppds=no
 fi
@@ -7839,6 +7845,13 @@
 fi
 AC_SUBST([ENABLE_EOT])
 
+if test "$enable_old_doc_filters" = "no"; then
+    BUILD_OLD_DOC_FILTERS=NO
+else
+    BUILD_OLD_DOC_FILTERS=YES
+fi
+AC_SUBST(BUILD_OLD_DOC_FILTERS)
+
 dnl ===================================================================
 dnl Check for DLP libs
 dnl ===================================================================
@@ -7848,44 +7861,122 @@
 )
 libo_CHECK_SYSTEM_MODULE([librevenge],[REVENGE],[librevenge-0.0 >= 0.0.1],["-I${WORKDIR}/UnpackedTarball/librevenge/inc"],["-L${librevenge_libdir} -lrevenge-0.0"])
 
-libo_CHECK_SYSTEM_MODULE([libodfgen],[ODFGEN],[libodfgen-0.1])
+if test "$BUILD_OLD_DOC_FILTERS" = "NO"; then
+    AC_MSG_CHECKING([which libodfgen to use])
+    AC_MSG_RESULT([none])
+    SYSTEM_ODFGEN=
+else
+    libo_CHECK_SYSTEM_MODULE([libodfgen],[ODFGEN],[libodfgen-0.1])
+fi
 
-AS_IF([test "$COM" = "MSC"],
-      [libwpd_libdir="${WORKDIR}/LinkTarget/Library"],
-      [libwpd_libdir="${WORKDIR}/UnpackedTarball/libwpd/src/lib/.libs"]
-)
-libo_CHECK_SYSTEM_MODULE([libwpd],[WPD],[libwpd-0.10],["-I${WORKDIR}/UnpackedTarball/libwpd/inc"],["-L${libwpd_libdir} -lwpd-0.10"])
+if test "$BUILD_OLD_DOC_FILTERS" = "NO"; then
+    AC_MSG_CHECKING([which libwpd to use])
+    AC_MSG_RESULT([none])
+    SYSTEM_WPD=NO
+else
+    AS_IF([test "$COM" = "MSC"],
+          [libwpd_libdir="${WORKDIR}/LinkTarget/Library"],
+          [libwpd_libdir="${WORKDIR}/UnpackedTarball/libwpd/src/lib/.libs"]
+    )
+    libo_CHECK_SYSTEM_MODULE([libwpd],[WPD],[libwpd-0.10],["-I${WORKDIR}/UnpackedTarball/libwpd/inc"],["-L${libwpd_libdir} -lwpd-0.10"])
+fi
 
-libo_CHECK_SYSTEM_MODULE([libwpg],[WPG],[libwpg-0.3])
+if test "$BUILD_OLD_DOC_FILTERS" = "NO"; then
+    AC_MSG_CHECKING([which libwpg to use])
+    AC_MSG_RESULT([none])
+    SYSTEM_WPG=NO
+else
+    libo_CHECK_SYSTEM_MODULE([libwpg],[WPG],[libwpg-0.3])
+fi
 
-libo_CHECK_SYSTEM_MODULE([libwps],[WPS],[libwps-0.4])
-libo_PKG_VERSION([WPS], [libwps-0.4], [0.4.6])
+if test "$BUILD_OLD_DOC_FILTERS" = "NO"; then
+    AC_MSG_CHECKING([which libwps to use])
+    AC_MSG_RESULT([none])
+    SYSTEM_WPS=
+else
+    libo_CHECK_SYSTEM_MODULE([libwps],[WPS],[libwps-0.4])
+    libo_PKG_VERSION([WPS], [libwps-0.4], [0.4.6])
+fi
 
-libo_CHECK_SYSTEM_MODULE([libvisio],[VISIO],[libvisio-0.1])
+if test "$BUILD_OLD_DOC_FILTERS" = "NO"; then
+    AC_MSG_CHECKING([which libvisio to use])
+    AC_MSG_RESULT([none])
+    SYSTEM_VISIO=
+else
+    libo_CHECK_SYSTEM_MODULE([libvisio],[VISIO],[libvisio-0.1])
+fi
 
-libo_CHECK_SYSTEM_MODULE([libcdr],[CDR],[libcdr-0.1])
+if test "$BUILD_OLD_DOC_FILTERS" = "NO"; then
+    AC_MSG_CHECKING([which libcdr to use])
+    AC_MSG_RESULT([none])
+    SYSTEM_CDR=
+else
+    libo_CHECK_SYSTEM_MODULE([libcdr],[CDR],[libcdr-0.1])
+fi
 
-libo_CHECK_SYSTEM_MODULE([libmspub],[MSPUB],[libmspub-0.1])
+if test "$BUILD_OLD_DOC_FILTERS" = "NO"; then
+    AC_MSG_CHECKING([which libmspub to use])
+    AC_MSG_RESULT([none])
+    SYSTEM_MSPUB=
+else
+    libo_CHECK_SYSTEM_MODULE([libmspub],[MSPUB],[libmspub-0.1])
+fi
 
-libo_CHECK_SYSTEM_MODULE([libmwaw],[MWAW],[libmwaw-0.3 >= 0.3.1])
-libo_PKG_VERSION([MWAW], [libmwaw-0.3], [0.3.11])
+if test "$BUILD_OLD_DOC_FILTERS" = "NO"; then
+    AC_MSG_CHECKING([which libmwaw to use])
+    AC_MSG_RESULT([none])
+    SYSTEM_MWAW=
+else
+    libo_CHECK_SYSTEM_MODULE([libmwaw],[MWAW],[libmwaw-0.3 >= 0.3.1])
+    libo_PKG_VERSION([MWAW], [libmwaw-0.3], [0.3.11])
+fi
 
-libo_CHECK_SYSTEM_MODULE([libetonyek],[ETONYEK],[libetonyek-0.1])
-libo_PKG_VERSION([ETONYEK], [libetonyek-0.1], [0.1.5])
+if test "$BUILD_OLD_DOC_FILTERS" = "NO"; then
+    AC_MSG_CHECKING([which libetonyek to use])
+    AC_MSG_RESULT([none])
+    SYSTEM_ETONYEK=
+else
+    libo_CHECK_SYSTEM_MODULE([libetonyek],[ETONYEK],[libetonyek-0.1])
+    libo_PKG_VERSION([ETONYEK], [libetonyek-0.1], [0.1.5])
+fi
 
-libo_CHECK_SYSTEM_MODULE([libfreehand],[FREEHAND],[libfreehand-0.1])
+if test "$BUILD_OLD_DOC_FILTERS" = "NO"; then
+    AC_MSG_CHECKING([which libfreehand to use])
+    AC_MSG_RESULT([none])
+    SYSTEM_FREEHAND=
+else
+    libo_CHECK_SYSTEM_MODULE([libfreehand],[FREEHAND],[libfreehand-0.1])
+fi
 
 libo_CHECK_SYSTEM_MODULE([libebook],[EBOOK],[libe-book-0.1])
 libo_PKG_VERSION([EBOOK], [libe-book-0.1], [0.1.2])
 
-libo_CHECK_SYSTEM_MODULE([libabw],[ABW],[libabw-0.1])
+if test "$BUILD_OLD_DOC_FILTERS" = "NO"; then
+    AC_MSG_CHECKING([which libabw to use])
+    AC_MSG_RESULT([none])
+    SYSTEM_ABW=
+else
+    libo_CHECK_SYSTEM_MODULE([libabw],[ABW],[libabw-0.1])
+fi
 
-libo_CHECK_SYSTEM_MODULE([libpagemaker],[PAGEMAKER],[libpagemaker-0.0])
+if test "$BUILD_OLD_DOC_FILTERS" = "NO"; then
+    AC_MSG_CHECKING([which libpagemaker to use])
+    AC_MSG_RESULT([none])
+    SYSTEM_PAGEMAKER=
+else
+    libo_CHECK_SYSTEM_MODULE([libpagemaker],[PAGEMAKER],[libpagemaker-0.0])
+fi
 
 libo_CHECK_SYSTEM_MODULE([libzmf],[ZMF],[libzmf-0.0])
 
-libo_CHECK_SYSTEM_MODULE([libstaroffice],[STAROFFICE],[libstaroffice-0.0])
-libo_PKG_VERSION([STAROFFICE], [libstaroffice-0.0], [0.0.3])
+if test "$BUILD_OLD_DOC_FILTERS" = "NO"; then
+    AC_MSG_CHECKING([which libstaroffice to use])
+    AC_MSG_RESULT([none])
+    SYSTEM_STAROFFICE=
+else
+    libo_CHECK_SYSTEM_MODULE([libstaroffice],[STAROFFICE],[libstaroffice-0.0])
+    libo_PKG_VERSION([STAROFFICE], [libstaroffice-0.0], [0.0.3])
+fi
 
 dnl ===================================================================
 dnl Check for system libcmis
diff -urN libreoffice-5.4.2.2-orig/postprocess/Rdb_services.mk libreoffice-5.4.2.2/postprocess/Rdb_services.mk
--- libreoffice-5.4.2.2-orig/postprocess/Rdb_services.mk	2017-09-28 03:03:26 +0900
+++ libreoffice-5.4.2.2/postprocess/Rdb_services.mk	2017-11-08 19:02:49 +0900
@@ -118,10 +118,12 @@
 		sccomp/source/solver/lpsolvesolver \
 	) \
 	writerfilter/util/writerfilter \
-	writerperfect/source/draw/wpftdraw \
-	writerperfect/source/impress/wpftimpress \
-	writerperfect/source/writer/wpftwriter \
-	writerperfect/source/calc/wpftcalc \
+	$(if $(filter YES,$(BUILD_OLD_DOC_FILTERS)), \
+		writerperfect/source/draw/wpftdraw \
+		writerperfect/source/impress/wpftimpress \
+		writerperfect/source/writer/wpftwriter \
+		writerperfect/source/calc/wpftcalc \
+	) \
 	$(if $(filter MACOSX,$(OS)), \
 		$(call gb_Helper_optional,AVMEDIA,avmedia/source/macavf/avmediaMacAVF) \
 		$(if $(filter TRUE,$(ENABLE_MACOSX_SANDBOX)),, \
diff -urN libreoffice-5.4.2.2-orig/scp2/InstallModule_ooo.mk libreoffice-5.4.2.2/scp2/InstallModule_ooo.mk
--- libreoffice-5.4.2.2-orig/scp2/InstallModule_ooo.mk	2017-09-28 03:03:26 +0900
+++ libreoffice-5.4.2.2/scp2/InstallModule_ooo.mk	2017-11-08 19:03:10 +0900
@@ -19,6 +19,7 @@
 ))
 
 $(eval $(call gb_InstallModule_define_if_set,scp2/ooo,\
+	BUILD_OLD_DOC_FILTERS \
 	ENABLE_SYSTRAY_GTK \
 	ENABLE_MACOSX_SANDBOX \
 	ENABLE_ONLINE_UPDATE \
diff -urN libreoffice-5.4.2.2-orig/scp2/source/ooo/file_ooo.scp libreoffice-5.4.2.2/scp2/source/ooo/file_ooo.scp
--- libreoffice-5.4.2.2-orig/scp2/source/ooo/file_ooo.scp	2017-09-28 03:03:26 +0900
+++ libreoffice-5.4.2.2/scp2/source/ooo/file_ooo.scp	2017-11-08 19:02:49 +0900
@@ -174,7 +174,9 @@
 UI_FILELIST(swxform, "UIConfig/modules/swxform.filelist")
 UI_FILELIST(uui, "UIConfig/uui.filelist")
 UI_FILELIST(vcl, "UIConfig/vcl.filelist")
+#ifdef BUILD_OLD_DOC_FILTERS
 UI_FILELIST(writerperfect, "UIConfig/writerperfect.filelist")
+#endif
 UI_FILELIST(xmlsec, "UIConfig/xmlsec.filelist")
 
 UI_FILELIST_ALL_LANG(basicide, modules/BasicIDE)
diff -urN libreoffice-5.4.2.2-orig/scp2/source/ooo/file_resource_ooo.scp libreoffice-5.4.2.2/scp2/source/ooo/file_resource_ooo.scp
--- libreoffice-5.4.2.2-orig/scp2/source/ooo/file_resource_ooo.scp	2017-09-28 03:03:26 +0900
+++ libreoffice-5.4.2.2/scp2/source/ooo/file_resource_ooo.scp	2017-11-08 19:02:49 +0900
@@ -91,7 +91,9 @@
 
 STD_RES_FILE( gid_File_Res_Vcl, vcl )
 
+#ifdef BUILD_OLD_DOC_FILTERS
 STD_RES_FILE( gid_File_Res_Writerperfect, writerperfect )
+#endif
 
 STD_RES_FILE( gid_File_Res_Xsltdlg, xsltdlg )
 
diff -urN libreoffice-5.4.2.2-orig/writerperfect/Module_writerperfect.mk libreoffice-5.4.2.2/writerperfect/Module_writerperfect.mk
--- libreoffice-5.4.2.2-orig/writerperfect/Module_writerperfect.mk	2017-09-28 03:03:26 +0900
+++ libreoffice-5.4.2.2/writerperfect/Module_writerperfect.mk	2017-11-08 19:02:49 +0900
@@ -19,6 +19,8 @@
 
 $(eval $(call gb_Module_Module,writerperfect))
 
+ifneq (NO,$(BUILD_OLD_DOC_FILTERS))
+
 $(eval $(call gb_Module_add_targets,writerperfect,\
 	Library_wpftcalc \
 	Library_wpftdraw \
@@ -46,4 +48,6 @@
 	Library_wpftqahelper \
 ))
 
+endif
+
 # vim: set noet sw=4 ts=4:
