summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.fetch1
-rw-r--r--RepositoryExternal.mk41
-rw-r--r--config_host.mk.in1
-rw-r--r--configure.ac72
-rw-r--r--download.lst2
-rw-r--r--external/Module_external.mk1
-rw-r--r--external/udunits2/ExternalPackage_udunits2.mk25
-rw-r--r--external/udunits2/ExternalProject_udunits2.mk33
-rw-r--r--external/udunits2/Makefile7
-rw-r--r--external/udunits2/Module_udunits2.mk22
-rw-r--r--external/udunits2/README8
-rw-r--r--external/udunits2/UnpackedTarball_udunits2.mk14
-rw-r--r--sc/Library_sc.mk15
-rw-r--r--sc/source/core/inc/units.hxx41
-rw-r--r--sc/source/core/units/units.cxx36
15 files changed, 319 insertions, 0 deletions
diff --git a/Makefile.fetch b/Makefile.fetch
index 7aee66a1435e..49d513063e27 100644
--- a/Makefile.fetch
+++ b/Makefile.fetch
@@ -201,6 +201,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_host.mk $(SRCDIR)/download.lst $(SRCDIR)
$(call fetch_Optional,RHINO,SWING_TARBALL) \
$(call fetch_Optional,SERF,SERF_TARBALL) \
$(call fetch_Optional,UCPP,UCPP_TARBALL) \
+ $(call fetch_Optional,UDUNITS2,UDUNITS2_TARBALL) \
$(call fetch_Optional,VIGRA,VIGRA_TARBALL) \
$(call fetch_Optional,VISIO,VISIO_TARBALL) \
$(call fetch_Optional,WPD,WPD_TARBALL) \
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 47f6e90d9268..425fba047370 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -139,6 +139,47 @@ endef
endif # SYSTEM_MDDS
+ifeq ($(ENABLE_CALC_UNITVERIFICATION),TRUE)
+
+ifneq ($(SYSTEM_UDUNITS2),)
+
+define gb_LinkTarget__use_libudunits2
+$(call gb_LinkTarget_set_include,$(1),\
+ $(UDUNITS2_CFLAGS) \
+ $$(INCLUDE) \
+)
+$(call gb_LinkTarget_add_libs,$(1),$(UDUNIT2_LIBS))
+
+endef
+
+else # !SYSTEM_UDUNITS2
+
+define gb_LinkTarget__use_libudunits2
+$(call gb_LinkTarget_use_package,$(1),udunits2)
+$(call gb_LinkTarget_set_include,$(1),\
+ $$(INCLUDE) \
+ -I$(call gb_UnpackedTarball_get_dir,udunits2)/lib \
+)
+ifeq ($(COM),MSC)
+$(call gb_LinkTarget_add_libs,$(1),\
+ $(call gb_UnpackedTarball_get_dir,udunits2)/udunits2.lib \
+)
+else
+$(call gb_LinkTarget_add_libs,$(1),\
+ -L$(call gb_UnpackedTarball_get_dir,udunits2)/lib -ludunits2 \
+)
+endif
+
+endef
+
+endif # !SYSTEM_UDUNITS2
+
+else # !ENABLE_CALC_UNITVERIFICATION
+
+gb_LinkTarget__use_libudunits2 :=
+
+endif # ENABLE_CALC_UNITVERIFICATION
+
ifneq ($(SYSTEM_GLM),)
gb_LinkTarget__use_glm_headers :=
diff --git a/config_host.mk.in b/config_host.mk.in
index a23629f05098..ab06e8a69a8c 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -177,6 +177,7 @@ export ENABLE_SYSTRAY_GTK=@ENABLE_SYSTRAY_GTK@
export ENABLE_TDE=@ENABLE_TDE@
export ENABLE_TDEAB=@ENABLE_TDEAB@
export ENABLE_TELEPATHY=@ENABLE_TELEPATHY@
+export ENABLE_CALC_UNITVERIFICATION=@ENABLE_CALC_UNITVERIFICATION@
export ENABLE_VALGRIND=@ENABLE_VALGRIND@
export ENABLE_VLC=@ENABLE_VLC@
export ENABLE_WERROR=@ENABLE_WERROR@
diff --git a/configure.ac b/configure.ac
index e716ad011533..3e3fd2f304a8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1396,6 +1396,11 @@ AC_ARG_ENABLE(firebird-sdbc,
[Disable the build of the Firebird-SDBC driver if it doesn't compile for you.]),
,enable_firebird_sdbc=yes)
+AC_ARG_ENABLE(calc-unitverification,
+ AS_HELP_STRING([--enable-calc-unitverification],
+ [Enable the experimental unit verification features. Only use if you actively want to hack on this.]),
+)
+
AC_ARG_ENABLE(winegcc,
AS_HELP_STRING([--enable-winegcc],
[Enable use of winegcc during the build, in order to create msi* tools
@@ -1684,6 +1689,11 @@ AC_ARG_WITH(system-firebird,
driver. If fb_config is not in PATH, use FBCONFIG to point to it.]),,
[with_system_firebird="$with_system_libs"])
+AC_ARG_WITH(system-udunits2,
+ AS_HELP_STRING([--with-system-udunits2],
+ [Use udunits libraries already on system, for building calc unit-verification it.]),,
+ [with_system_udunits2="$with_system_libs"])
+
AC_ARG_WITH(system-hsqldb,
AS_HELP_STRING([--with-system-hsqldb],
[Use hsqldb already on system.]))
@@ -8536,6 +8546,68 @@ dnl ===================================================================
libo_CHECK_SYSTEM_MODULE([mdds], [MDDS], [mdds >= 0.10.3], ["-I${WORKDIR}/UnpackedTarball/mdds/include"])
dnl ===================================================================
+dnl Check for calc unit-verification
+dnl ===================================================================
+ENABLE_CALC_UNITVERIFICATION=""
+if test "x$enable_calc_unitverification" = "xyes"; then
+ SCPDEFS="$SCPDEFS -DWITH_CALC_UNITVERIFICATION"
+
+ dnl ===================================================================
+ dnl Check for system udunits2
+ dnl ===================================================================
+ AC_MSG_CHECKING([which udunits2 to use])
+ if test "$with_system_udunits2" = "yes"; then
+ AC_MSG_RESULT([external])
+ SYSTEM_UDUNITS2=TRUE
+ AC_PATH_PROG(FIREBIRDCONFIG, [fb_config])
+ if test -z "$FIREBIRDCONFIG"; then
+ AC_MSG_NOTICE([No fb_config -- using pkg-config])
+ PKG_CHECK_MODULES(FIREBIRD, fbembed)
+ FIREBIRD_VERSION=`pkg-config --modversion fbembed`
+ else
+ AC_MSG_NOTICE([fb_config found])
+ FIREBIRD_VERSION=`$FIREBIRDCONFIG --version`
+ AC_MSG_CHECKING([for Firebird Client library])
+ FIREBIRD_CFLAGS=`$FIREBIRDCONFIG --cflags`
+ FIREBIRD_LIBS=`$FIREBIRDCONFIG --embedlibs`
+ fi
+ AC_MSG_RESULT([includes `$FIREBIRD_CFLAGS', libraries `$FIREBIRD_LIBS'])
+ AC_MSG_CHECKING([Firebird version])
+ if test -n "${FIREBIRD_VERSION}"; then
+ FIREBIRD_MAJOR=`echo $FIREBIRD_VERSION | cut -d"." -f1`
+ FIREBIRD_MINOR=`echo $FIREBIRD_VERSION | cut -d"." -f2`
+ if test "$FIREBIRD_MAJOR" -eq "2" -a "$FIREBIRD_MINOR" -eq "5"; then
+ AC_MSG_RESULT([OK])
+ else
+ AC_MSG_ERROR([Ensure firebird 2.5.x is installed])
+ fi
+ else
+ __save_CFLAGS="${CFLAGS}"
+ CFLAGS="${CFLAGS} ${FIREBIRD_CFLAGS}"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <ibase.h>
+#if defined(FB_API_VER) && FB_API_VER == 25
+#else
+#error "Wrong Firebird API version"
+#endif]])],AC_MSG_RESULT([OK]),AC_MSG_ERROR([Ensure firebird 2.5.x is installed]))
+ CFLAGS="${__save_CFLAGS}"
+ fi
+ ENABLE_FIREBIRD_SDBC="TRUE"
+ else
+ AC_MSG_RESULT([internal])
+ SYSTEM_UDUNITS2=
+ UDUNITS2_CFLAGS="-I${WORKDIR}/UnpackedTarball/udunits2/lib"
+ UDUNITS2_LIBS="-ludunits2"
+
+ BUILD_TYPE="$BUILD_TYPE UDUNITS2"
+ ENABLE_CALC_UNITVERIFICATION="TRUE"
+ fi
+fi
+AC_SUBST(ENABLE_CALC_UNITVERIFICATION)
+AC_SUBST(SYSTEM_UDUNITS2)
+AC_SUBST(UDUNITS2_CFLAGS)
+AC_SUBST(UDUNITS2_LIBS)
+
+dnl ===================================================================
dnl Check for system glm
dnl ===================================================================
AC_MSG_CHECKING([which glm to use])
diff --git a/download.lst b/download.lst
index aa700aad79f9..2a8d850c5e41 100644
--- a/download.lst
+++ b/download.lst
@@ -136,6 +136,8 @@ export SERF_MD5SUM := 4f8e76c9c6567aee1d66aba49f76a58b
export SERF_TARBALL := serf-1.2.1.tar.bz2
export SWING_TARBALL := 35c94d2df8893241173de1d16b6034c0-swingExSrc.zip
export UCPP_TARBALL := 0168229624cfac409e766913506961a8-ucpp-1.3.2.tar.gz
+export UDUNITS2_MD5SUM := a2492adfbd9ae2f05a331673a2067cab
+export UDUNITS2_TARBALL := udunits-2.2.17.tar.gz
export VIGRA_TARBALL := d62650a6f908e85643e557a236ea989c-vigra1.6.0.tar.gz
export VISIO_MD5SUM := 931588332ba44682c9cd5eefbd358ab4
export VISIO_TARBALL := libvisio-0.1.0.tar.bz2
diff --git a/external/Module_external.mk b/external/Module_external.mk
index 6d38fd583939..897ab15ba6cf 100644
--- a/external/Module_external.mk
+++ b/external/Module_external.mk
@@ -89,6 +89,7 @@ $(eval $(call gb_Module_add_moduledirs,external,\
$(call gb_Helper_optional,RHINO,rhino) \
$(call gb_Helper_optional,SERF,serf) \
$(call gb_Helper_optional,UCPP,ucpp) \
+ $(call gb_Helper_optional,UDUNITS2,udunits2) \
$(call gb_Helper_optional,VIGRA,vigra) \
$(call gb_Helper_optional,VISIO,libvisio) \
$(call gb_Helper_optional,WPD,libwpd) \
diff --git a/external/udunits2/ExternalPackage_udunits2.mk b/external/udunits2/ExternalPackage_udunits2.mk
new file mode 100644
index 000000000000..306ea7ea997f
--- /dev/null
+++ b/external/udunits2/ExternalPackage_udunits2.mk
@@ -0,0 +1,25 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_ExternalPackage_ExternalPackage,udunits2,udunits2))
+
+$(eval $(call gb_ExternalPackage_use_external_project,udunits2,udunits2))
+
+ifeq ($(OS)-$(COM),WNT-MSC)
+$(eval $(call gb_ExternalPackage_add_file,udunits2,$(LIBO_LIB_FOLDER)/iudunits2.dll,lib/.libs/iudunits2.dll))
+else ifeq ($(OS),MACOSX)
+$(eval $(call gb_ExternalPackage_add_file,udunits2,$(LIBO_LIB_FOLDER)/libudunits2.dylib,lib/.libs/libudunits2.dylib))
+else
+$(eval $(call gb_ExternalPackage_add_file,udunits2,$(LIBO_LIB_FOLDER)/libudunits2.so.0,lib/.libs/libudunits2.so.0.1.0))
+endif
+
+
+# TODO: we also need to grab the units database files (*.xml from lib/), and figure out where to put them in our LO installation.
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/udunits2/ExternalProject_udunits2.mk b/external/udunits2/ExternalProject_udunits2.mk
new file mode 100644
index 000000000000..6fdbefaf236d
--- /dev/null
+++ b/external/udunits2/ExternalProject_udunits2.mk
@@ -0,0 +1,33 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_ExternalProject_ExternalProject,udunits2))
+
+$(eval $(call gb_ExternalProject_use_autoconf,udunits2,configure))
+
+$(eval $(call gb_ExternalProject_use_autoconf,udunits2,build))
+
+$(eval $(call gb_ExternalProject_register_targets,udunits2,\
+ configure \
+ build \
+))
+
+$(call gb_ExternalProject_get_state_target,udunits2,build) : $(call gb_ExternalProject_get_state_target,udunits2,configure)
+ +$(call gb_ExternalProject_run,build,\
+ $(MAKE) \
+ )
+
+$(call gb_ExternalProject_get_state_target,udunits2,configure) :
+ $(call gb_ExternalProject_run,configure,\
+ autoreconf -i && \
+ MAKE=$(MAKE) ./configure \
+ --build=$(if $(filter WNT,$(OS)),i686-pc-cygwin,$(BUILD_PLATFORM)) \
+ )
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/udunits2/Makefile b/external/udunits2/Makefile
new file mode 100644
index 000000000000..e4968cf85fb6
--- /dev/null
+++ b/external/udunits2/Makefile
@@ -0,0 +1,7 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+
+module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+
+include $(module_directory)/../../solenv/gbuild/partial_build.mk
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/udunits2/Module_udunits2.mk b/external/udunits2/Module_udunits2.mk
new file mode 100644
index 000000000000..94ab072c65b9
--- /dev/null
+++ b/external/udunits2/Module_udunits2.mk
@@ -0,0 +1,22 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Module_Module,udunits2))
+
+ifeq ($(SYSTEM_UDUNITS2),)
+
+$(eval $(call gb_Module_add_targets,udunits2,\
+ ExternalPackage_udunits2 \
+ ExternalProject_udunits2 \
+ UnpackedTarball_udunits2 \
+))
+
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/udunits2/README b/external/udunits2/README
new file mode 100644
index 000000000000..595e34b48b50
--- /dev/null
+++ b/external/udunits2/README
@@ -0,0 +1,8 @@
+udunits allows for parsing and manipulation of (physical) units.
+
+Important: when updating it's necessary to obtain the tarball from
+the official ftp site:
+ ftp://ftp.unidata.ucar.edu/pub/udunits/
+The tarballs from the github repository are missing autoconf and
+info files, i.e using these would require the installation of additional
+tooling, beyond what we already require for LibreOffice.
diff --git a/external/udunits2/UnpackedTarball_udunits2.mk b/external/udunits2/UnpackedTarball_udunits2.mk
new file mode 100644
index 000000000000..db096ca51446
--- /dev/null
+++ b/external/udunits2/UnpackedTarball_udunits2.mk
@@ -0,0 +1,14 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_UnpackedTarball_UnpackedTarball,udunits2))
+
+$(eval $(call gb_UnpackedTarball_set_tarball,udunits2,$(UDUNITS2_TARBALL)))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 898284e74221..cb132f3d126e 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -24,6 +24,12 @@ $(eval $(call gb_Library_set_include,sc,\
$$(INCLUDE) \
))
+ifeq ($(ENABLE_CALC_UNITVERIFICATION),TRUE)
+$(eval $(call gb_Library_add_defs,sc,\
+ -DENABLE_CALC_UNITVERIFICATION \
+))
+endif
+
$(eval $(call gb_Library_add_defs,sc,\
-DSC_DLLIMPLEMENTATION \
-DSC_INFO_OSVERSION=\"$(OS)\" \
@@ -41,6 +47,9 @@ $(eval $(call gb_Library_use_externals,sc,\
icui18n \
icuuc \
libxml2 \
+ $(if $(ENABLE_CALC_UNITVERIFICATION), \
+ libudunits2 \
+ ) \
mdds_headers \
))
@@ -676,6 +685,12 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/core/opencl/clcc/clew \
))
+ifeq ($(ENABLE_CALC_UNITVERIFICATION),TRUE)
+$(eval $(call gb_Library_add_exception_objects,sc,\
+ sc/source/core/units/units \
+))
+endif
+
ifeq ($(OS),LINUX)
$(eval $(call gb_Library_add_libs,sc,\
-ldl \
diff --git a/sc/source/core/inc/units.hxx b/sc/source/core/inc/units.hxx
new file mode 100644
index 000000000000..a4fef34489e3
--- /dev/null
+++ b/sc/source/core/inc/units.hxx
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SC_SOURCE_CORE_INC_UNITS_HXX
+#define INCLUDED_SC_SOURCE_CORE_INC_UNITS_HXX
+
+#include <boost/shared_ptr.hpp>
+
+struct ut_system;
+
+namespace sc { namespace units {
+
+class Units {
+private:
+ ::boost::shared_ptr< ut_system > mpUnitSystem;
+
+public:
+ Units();
+};
+
+}} // namespace sc::units
+
+#endif // INCLUDED_SC_SOURCE_CORE_INC_UNITS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+
diff --git a/sc/source/core/units/units.cxx b/sc/source/core/units/units.cxx
new file mode 100644
index 000000000000..585b2c56aa5d
--- /dev/null
+++ b/sc/source/core/units/units.cxx
@@ -0,0 +1,36 @@
+/* -*- 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 "units.hxx"
+
+#include <udunits2.h>
+
+using namespace sc::units;
+
+static void freeUtSystem( ut_system* pSystem ) {
+ ut_free_system( pSystem );
+}
+
+Units::Units() {
+ // TODO: we need to get the path for our unit database, but only
+ // if using bundled udunits.
+ mpUnitSystem = boost::shared_ptr< ut_system >( ut_read_xml( 0 ),
+ &freeUtSystem );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */