diff --git a/Makefile.fetch b/Makefile.fetch
index 20402ba1dad8..94f697ea9270 100644
--- a/Makefile.fetch
+++ b/Makefile.fetch
@@ -131,6 +131,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_$(gb_Side).mk $(SRCDIR)/download.lst $(S
$(call fetch_Optional,GPGMEPP,GPGME_TARBALL) \
$(call fetch_Optional,GRAPHITE,GRAPHITE_TARBALL) \
$(call fetch_Optional,HARFBUZZ,HARFBUZZ_TARBALL) \
+ $(call fetch_Optional,HSQLDB,HSQLDB_TARBALL) \
$(call fetch_Optional,HUNSPELL,HUNSPELL_TARBALL) \
$(call fetch_Optional,HYPHEN,HYPHEN_TARBALL) \
$(call fetch_Optional,ICU,ICU_TARBALL) \
diff --git a/Repository.mk b/Repository.mk
index c57906d74c20..69bcdae4d396 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -604,6 +604,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,PLAINLIBS_OOO,ooo, \
dict_ja \
dict_zh \
embobj \
+ $(if $(ENABLE_JAVA),hsqldb) \
i18nutil \
index_data \
$(if $(and $(ENABLE_GTK3), $(filter LINUX %BSD SOLARIS,$(OS))), libreofficekitgtk) \
@@ -738,6 +739,7 @@ $(eval $(call gb_Helper_register_jars_for_install,OOO,ooo, \
$(if $(filter-out MACOSX,$(OS)),officebean) \
query \
report \
+ sdbc_hsqldb \
smoketest \
table \
unoil \
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index f6144e4fa613..aecbd71b8b43 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -2856,6 +2856,26 @@ $(call gb_LinkTarget_set_include,$(1),\
)
endef
+ifneq ($(SYSTEM_HSQLDB),)
+
+define gb_LinkTarget__use_hsqldb
+
+$(call gb_LinkTarget_add_defs,$(1),\
+ -DSYSTEM_HSQLDB \
+ -DHSQLDB_JAR=\""file://$(HSQLDB_JAR)"\" \
+)
+
+endef
+
+else # !SYSTEM_HSQLDB
+
+define gb_LinkTarget__use_hsqldb
+
+endef
+
+endif # SYSTEM_HSQLDB
+
+
ifneq ($(SYSTEM_OPENLDAP),)
define gb_LinkTarget__use_openldap
@@ -3612,6 +3632,33 @@ endef
### Jars ############################################################
+ifneq ($(SYSTEM_HSQLDB),)
+
+define gb_Jar__use_hsqldb
+$(call gb_Jar_use_system_jar,$(1),$(HSQLDB_JAR))
+endef
+define gb_JunitTest__use_hsqldb
+$(call gb_JunitTest_use_system_jar,$(1),$(HSQLDB_JAR))
+endef
+
+else # !SYSTEM_HSQLDB
+
+ifeq ($(ENABLE_JAVA),TRUE)
+$(eval $(call gb_Helper_register_jars_for_install,OOO,ooo, \
+ hsqldb \
+))
+endif
+
+define gb_Jar__use_hsqldb
+$(call gb_Jar_use_jar,$(1),hsqldb)
+endef
+define gb_JunitTest__use_hsqldb
+$(call gb_JunitTest_use_jar,$(1),hsqldb)
+endef
+
+endif # SYSTEM_HSQLDB
+
+
ifeq ($(ENABLE_SCRIPTING_BEANSHELL),TRUE)
ifneq ($(SYSTEM_BSH),)
diff --git a/RepositoryFixes.mk b/RepositoryFixes.mk
index a8536f389e0d..82c0701e59dd 100644
--- a/RepositoryFixes.mk
+++ b/RepositoryFixes.mk
@@ -45,6 +45,8 @@ gb_Library_FILENAMES := \
$(subst jpipe:libjpipe.dylib,jpipe:libjpipe.jnilib,$(gb_Library_FILENAMES))
gb_Library_FILENAMES := \
$(subst juh:libjuh.dylib,juh:libjuh.jnilib,$(gb_Library_FILENAMES))
+gb_Library_FILENAMES := \
+ $(subst hsqldb:libhsqldb.dylib,hsqldb:libhsqldb.jnilib,$(gb_Library_FILENAMES))
endif
# fixes for all the libraries that are named with too much creativity and do
diff --git a/config_host.mk.in b/config_host.mk.in
index 8a0722336fd7..965cdaf6887a 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -254,6 +254,8 @@ export HAVE_POSIX_FALLOCATE=@HAVE_POSIX_FALLOCATE@
export HELP_COMMON_ONLY=@HELP_COMMON_ONLY@
export HELP_ONLINE=@HELP_ONLINE@
export HOST_PLATFORM=@host@
+export HSQLDB_JAR=@HSQLDB_JAR@
+export HSQLDB_USE_JDBC_4_1=@HSQLDB_USE_JDBC_4_1@
export HUNSPELL_CFLAGS=$(gb_SPACE)@HUNSPELL_CFLAGS@
export HUNSPELL_LIBS=$(gb_SPACE)@HUNSPELL_LIBS@
export HYPHEN_LIB=$(gb_SPACE)@HYPHEN_LIB@
@@ -526,6 +528,7 @@ export SYSTEM_GLM=@SYSTEM_GLM@
export SYSTEM_GPGMEPP=@SYSTEM_GPGMEPP@
export SYSTEM_GRAPHITE=@SYSTEM_GRAPHITE@
export SYSTEM_HARFBUZZ=@SYSTEM_HARFBUZZ@
+export SYSTEM_HSQLDB=@SYSTEM_HSQLDB@
export SYSTEM_HUNSPELL=@SYSTEM_HUNSPELL@
export SYSTEM_HYPH=@SYSTEM_HYPH@
export SYSTEM_ICU=@SYSTEM_ICU@
diff --git a/configure.ac b/configure.ac
index ce3dcd67f1d1..e4f2bb53770d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1739,6 +1739,15 @@ AC_ARG_WITH(system-libtommath,
[Use libtommath already on system]),,
[with_system_libtommath="$with_system_libs"])
+AC_ARG_WITH(system-hsqldb,
+ AS_HELP_STRING([--with-system-hsqldb],
+ [Use hsqldb already on system.]))
+
+AC_ARG_WITH(hsqldb-jar,
+ AS_HELP_STRING([--with-hsqldb-jar=JARFILE],
+ [Specify path to jarfile manually.]),
+ HSQLDB_JAR=$withval)
+
libo_FUZZ_ARG_ENABLE(scripting-beanshell,
AS_HELP_STRING([--disable-scripting-beanshell],
[Disable support for scripts in BeanShell.]),
@@ -8418,6 +8427,75 @@ int main(int argc, char **argv) {
fi
AC_SUBST(SYSTEM_MYSQL_CONNECTOR_CPP)
+dnl ===================================================================
+dnl Check for system hsqldb
+dnl ===================================================================
+if test "$with_java" != "no"; then
+ HSQLDB_USE_JDBC_4_1=
+ AC_MSG_CHECKING([which hsqldb to use])
+ if test "$with_system_hsqldb" = "yes"; then
+ AC_MSG_RESULT([external])
+ SYSTEM_HSQLDB=TRUE
+ if test -z $HSQLDB_JAR; then
+ HSQLDB_JAR=/usr/share/java/hsqldb.jar
+ fi
+ if ! test -f $HSQLDB_JAR; then
+ AC_MSG_ERROR(hsqldb.jar not found.)
+ fi
+ AC_MSG_CHECKING([whether hsqldb is 1.8.0.x])
+ export HSQLDB_JAR
+ if $PERL -e \
+ 'use Archive::Zip;
+ my $file = "$ENV{'HSQLDB_JAR'}";
+ my $zip = Archive::Zip->new( $file );
+ my $mf = $zip->contents ( "META-INF/MANIFEST.MF" );
+ if ( $mf =~ m/Specification-Version: 1.8.*/ )
+ {
+ push @l, split(/\n/, $mf);
+ foreach my $line (@l)
+ {
+ if ($line =~ m/Specification-Version:/)
+ {
+ ($t, $version) = split (/:/,$line);
+ $version =~ s/^\s//;
+ ($a, $b, $c, $d) = split (/\./,$version);
+ if ($c == "0" && $d > "8")
+ {
+ exit 0;
+ }
+ else
+ {
+ exit 1;
+ }
+ }
+ }
+ }
+ else
+ {
+ exit 1;
+ }'; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_ERROR([no, you need hsqldb >= 1.8.0.9 but < 1.8.1])
+ fi
+ else
+ AC_MSG_RESULT([internal])
+ SYSTEM_HSQLDB=
+ BUILD_TYPE="$BUILD_TYPE HSQLDB"
+ AC_MSG_CHECKING([whether hsqldb should be built with JDBC 4.1])
+ javanumver=`$JAVAINTERPRETER -version 2>&1 | $AWK -v num=true -f $SRC_ROOT/solenv/bin/getcompver.awk`
+ if expr "$javanumver" '>=' 000100060000 > /dev/null; then
+ AC_MSG_RESULT([yes])
+ HSQLDB_USE_JDBC_4_1=TRUE
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+ AC_SUBST(SYSTEM_HSQLDB)
+ AC_SUBST(HSQLDB_JAR)
+ AC_SUBST([HSQLDB_USE_JDBC_4_1])
+fi
+
dnl ===================================================================
dnl Check for PostgreSQL stuff
dnl ===================================================================
diff --git a/connectivity/Configuration_hsqldb.mk b/connectivity/Configuration_hsqldb.mk
new file mode 100644
index 000000000000..a9528cf4973c
--- /dev/null
+++ b/connectivity/Configuration_hsqldb.mk
@@ -0,0 +1,20 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Configuration_Configuration,driver_hsqldb))
+
+$(eval $(call gb_Configuration_add_spool_modules,driver_hsqldb,connectivity/registry/hsqldb,\
+ org/openoffice/Office/DataAccess/Drivers-hsqldb.xcu \
+))
+
+$(eval $(call gb_Configuration_add_localized_datas,driver_hsqldb,connectivity/registry/hsqldb,\
+ org/openoffice/Office/DataAccess/Drivers.xcu \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/connectivity/Jar_sdbc_hsqldb.mk b/connectivity/Jar_sdbc_hsqldb.mk
new file mode 100644
index 000000000000..20cd1f8ae044
--- /dev/null
+++ b/connectivity/Jar_sdbc_hsqldb.mk
@@ -0,0 +1,37 @@
+# -*- 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_Jar_Jar,sdbc_hsqldb))
+
+$(eval $(call gb_Jar_use_externals,sdbc_hsqldb,\
+ hsqldb \
+))
+
+$(eval $(call gb_Jar_add_manifest_classpath,sdbc_hsqldb,\
+ $(if $(filter MACOSX,$(OS)),../../Frameworks/,..) \
+))
+
+$(eval $(call gb_Jar_set_packageroot,sdbc_hsqldb,com))
+
+$(eval $(call gb_Jar_add_packagedir,sdbc_hsqldb,org))
+
+$(eval $(call gb_Jar_add_sourcefiles,sdbc_hsqldb,\
+ connectivity/org/hsqldb/lib/FileSystemRuntimeException \
+ connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper \
+ connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries \
+ connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper \
+ connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess \
+ connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess \
+ connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess \
+ connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream \
+ connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/connectivity/JunitTest_complex.mk b/connectivity/JunitTest_complex.mk
index 8893562589a3..78947bfc2076 100644
--- a/connectivity/JunitTest_complex.mk
+++ b/connectivity/JunitTest_complex.mk
@@ -22,6 +22,10 @@ $(eval $(call gb_JunitTest_use_jars,connectivity_complex,\
unoil \
))
+$(eval $(call gb_JunitTest_use_externals,connectivity_complex,\
+ hsqldb \
+))
+
$(eval $(call gb_JunitTest_add_classes,connectivity_complex,\
org.openoffice.test.UnoApiTest \
))
diff --git a/connectivity/Library_hsqldb.mk b/connectivity/Library_hsqldb.mk
new file mode 100644
index 000000000000..0685402145bb
--- /dev/null
+++ b/connectivity/Library_hsqldb.mk
@@ -0,0 +1,62 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Library_Library,hsqldb))
+
+$(eval $(call gb_Library_set_include,hsqldb,\
+ -I$(SRCDIR)/connectivity/inc \
+ -I$(SRCDIR)/connectivity/source/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_Library_use_externals,hsqldb,\
+ boost_headers \
+ hsqldb \
+))
+
+$(eval $(call gb_Library_use_sdk_api,hsqldb))
+
+$(eval $(call gb_Library_use_libraries,hsqldb,\
+ comphelper \
+ cppu \
+ cppuhelper \
+ dbtools \
+ jvmfwk \
+ sal \
+ salhelper \
+ tl \
+ utl \
+ i18nlangtag \
+))
+
+$(eval $(call gb_Library_set_componentfile,hsqldb,connectivity/source/drivers/hsqldb/hsqldb))
+
+$(eval $(call gb_Library_add_exception_objects,hsqldb,\
+ connectivity/source/drivers/hsqldb/HCatalog \
+ connectivity/source/drivers/hsqldb/HColumns \
+ connectivity/source/drivers/hsqldb/HConnection \
+ connectivity/source/drivers/hsqldb/HDriver \
+ connectivity/source/drivers/hsqldb/HStorageAccess \
+ connectivity/source/drivers/hsqldb/HStorageMap \
+ connectivity/source/drivers/hsqldb/HTable \
+ connectivity/source/drivers/hsqldb/HTables \
+ connectivity/source/drivers/hsqldb/HTerminateListener \
+ connectivity/source/drivers/hsqldb/HTools \
+ connectivity/source/drivers/hsqldb/HUser \
+ connectivity/source/drivers/hsqldb/HUsers \
+ connectivity/source/drivers/hsqldb/HView \
+ connectivity/source/drivers/hsqldb/HViews \
+ connectivity/source/drivers/hsqldb/Hservices \
+ connectivity/source/drivers/hsqldb/StorageFileAccess \
+ connectivity/source/drivers/hsqldb/StorageNativeInputStream \
+ connectivity/source/drivers/hsqldb/StorageNativeOutputStream \
+ connectivity/source/drivers/hsqldb/accesslog \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/connectivity/Module_connectivity.mk b/connectivity/Module_connectivity.mk
index 4a500eb3ea3d..3ba7ecf01d41 100644
--- a/connectivity/Module_connectivity.mk
+++ b/connectivity/Module_connectivity.mk
@@ -40,7 +40,10 @@ $(eval $(call gb_Module_add_l10n_targets,connectivity,\
ifneq ($(ENABLE_JAVA),)
$(eval $(call gb_Module_add_targets,connectivity,\
+ Configuration_hsqldb \
Configuration_jdbc \
+ Jar_sdbc_hsqldb \
+ Library_hsqldb \
Library_jdbc \
))
endif
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java
new file mode 100644
index 000000000000..66b6f5489862
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java
@@ -0,0 +1,62 @@
+/*
+ * 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 .
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+public class NativeInputStreamHelper extends java.io.InputStream{
+ private final String key;
+ private final String file;
+ private final StorageNativeInputStream in;
+ /** Creates a new instance of NativeInputStreamHelper */
+ public NativeInputStreamHelper(String key,String _file) {
+ file = _file;
+ this.key = key;
+ in = new StorageNativeInputStream(key,file);
+ }
+
+ @Override
+ public int read() throws java.io.IOException {
+ return in.read(key,file);
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws java.io.IOException {
+ return in.read(key,file,b,off,len);
+ }
+
+ @Override
+ public void close() throws java.io.IOException {
+ in.close(key,file);
+ }
+
+ @Override
+ public long skip(long n) throws java.io.IOException {
+ return in.skip(key,file,n);
+ }
+
+ @Override
+ public int available() throws java.io.IOException {
+ return in.available(key,file);
+ }
+
+ @Override
+ public int read(byte[] b) throws java.io.IOException {
+ return in.read(key,file,b);
+ }
+
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java
new file mode 100644
index 000000000000..59541556b185
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java
@@ -0,0 +1,71 @@
+/*
+ * 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 .
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+final class NativeLibraries {
+ public static void load() {
+ if (System.getProperty( "os.name" ).startsWith("Windows")) {
+ loadLibrary("msvcr71");
+ loadLibrary("sal3");
+ loadLibrary("dbtoolsmi");
+ }
+ loadLibrary("hsqldb");
+ }
+
+ private static void loadLibrary(String libname) {
+ // At least on Mac OS X Tiger, System.loadLibrary("hsqldb2") does not
+ // find the hsqldb2 library one directory above sdbc_hsqldb.jar, even
+ // though ".." is on the jar's Class-Path; however, the alternative
+ // code (needing Java 1.5, which is given for Mac OS X Tiger) works
+ // there:
+ try {
+ System.loadLibrary(libname);
+ } catch (UnsatisfiedLinkError e) {
+ ClassLoader cl = NativeLibraries.class.getClassLoader();
+ if (cl instanceof URLClassLoader) {
+ String sysname = System.mapLibraryName(libname);
+ // At least Oracle's 1.7.0_51 now maps to .dylib rather than
+ // .jnilib:
+ if (System.getProperty("os.name").startsWith("Mac")
+ && sysname.endsWith(".dylib"))
+ {
+ sysname
+ = sysname.substring(
+ 0, sysname.length() - "dylib".length())
+ + "jnilib";
+ }
+ URL url = ((URLClassLoader) cl).findResource(sysname);
+ if (url != null) {
+ try {
+ System.load(new File(url.toURI()).getAbsolutePath());
+ } catch (Throwable t) {
+ throw new UnsatisfiedLinkError(
+ e.toString()+ " - " + t.toString());
+ }
+ }
+ }
+ }
+ }
+
+ private NativeLibraries() {}
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java
new file mode 100644
index 000000000000..6445f24139d4
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java
@@ -0,0 +1,60 @@
+/*
+ * 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 .
+ */
+package com.sun.star.sdbcx.comp.hsqldb;
+
+public class NativeOutputStreamHelper extends java.io.OutputStream{
+
+ private final String key;
+ private final String file;
+ private final StorageNativeOutputStream out;
+ /** Creates a new instance of NativeOutputStreamHelper */
+ public NativeOutputStreamHelper(String key,String _file) {
+ file = _file;
+ this.key = key;
+ out = new StorageNativeOutputStream(file,key);
+ }
+
+ @Override
+ public void write(byte[] b, int off, int len) throws java.io.IOException{
+ out.write(key,file,b, off, len);
+ }
+
+ @Override
+ public void write(byte[] b) throws java.io.IOException{
+ out.write(key,file,b);
+ }
+
+ @Override
+ public void close() throws java.io.IOException{
+ out.close(key,file);
+ }
+
+ @Override
+ public void write(int b) throws java.io.IOException{
+ out.write(key,file,b);
+ }
+
+ @Override
+ public void flush() throws java.io.IOException{
+ out.flush(key,file);
+ }
+
+ public void sync() throws java.io.IOException{
+ out.sync(key,file);
+ }
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java
new file mode 100644
index 000000000000..5a9bc8bb6c4c
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java
@@ -0,0 +1,62 @@
+/*
+ * 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 .
+ */
+package com.sun.star.sdbcx.comp.hsqldb;
+
+public class NativeStorageAccess {
+ static { NativeLibraries.load(); }
+
+ public static final int READ = 1;
+ private static final int SEEKABLE = 2;
+ private static final int SEEKABLEREAD = 3;
+ public static final int WRITE = 4;
+ private static final int READWRITE = 7;
+ public static final int TRUNCATE = 8;
+
+ /** Creates a new instance of StorageAccess */
+ public NativeStorageAccess(String name,String _mode,Object key) throws java.io.IOException{
+ try {
+ int mode = NativeStorageAccess.SEEKABLEREAD;
+ if ( _mode.equals("rw") )
+ mode = NativeStorageAccess.READWRITE | NativeStorageAccess.SEEKABLE;
+
+ openStream(name, (String)key, mode);
+ } catch(Exception ex1){
+ java.io.IOException ex2 = new java.io.IOException();
+ ex2.initCause(ex1);
+ throw ex2;
+ }
+ }
+ private native void openStream(String name,String key, int mode);
+ public native void close(String name,String key) throws java.io.IOException;
+
+ public native long getFilePointer(String name,String key) throws java.io.IOException;
+
+ public native long length(String name,String key) throws java.io.IOException;
+
+ public native int read(String name,String key) throws java.io.IOException;
+
+ public native int read(String name,String key,byte[] b, int off, int len) throws java.io.IOException;
+
+
+
+ public native void seek(String name,String key,long position) throws java.io.IOException;
+
+ public native void write(String name,String key,byte[] b, int offset, int length) throws java.io.IOException;
+
+
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java
new file mode 100644
index 000000000000..6a53d110e661
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java
@@ -0,0 +1,126 @@
+/*
+ * 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 .
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+@SuppressWarnings("ucd")
+public class StorageAccess implements org.hsqldb.lib.Storage {
+ String key;
+ String name;
+ boolean readonly;
+ NativeStorageAccess access;
+ /** Creates a new instance of StorageAccess */
+ public StorageAccess(String name,Boolean readonly,Object key) throws java.io.IOException{
+ this.key = (String)key;
+ this.name = name;
+ this.readonly = readonly.booleanValue();
+ try {
+ access = new NativeStorageAccess(name,
+ this.readonly ? "r" : "rw"
+ ,key);
+ } catch(Exception ex1){
+ java.io.IOException ex2 = new java.io.IOException();
+ ex2.initCause(ex1);
+ throw ex2;
+ }
+ }
+ public void close() throws java.io.IOException{
+ access.close(name,key);
+ }
+
+ public long getFilePointer() throws java.io.IOException{
+ return access.getFilePointer(name,key);
+ }
+
+ public long length() throws java.io.IOException{
+ return access.length(name,key);
+ }
+
+ public int read() throws java.io.IOException{
+ return access.read(name,key);
+ }
+
+ public void read(byte[] b, int off, int len) throws java.io.IOException{
+ access.read(name,key,b,off,len);
+ }
+
+ // based on the same code that reads an int from the .data file in HSQLDB
+ public int readInt() throws java.io.IOException{
+ byte [] tmp = new byte [4];
+
+ int count = access.read(name,key,tmp,0, 4);
+
+ if (count != 4){
+ throw new java.io.IOException();
+ }
+
+ count = 0;
+ int ch0 = tmp[count++] & 0xff;
+ int ch1 = tmp[count++] & 0xff;
+ int ch2 = tmp[count++] & 0xff;
+ int ch3 = tmp[count] & 0xff;
+
+ return ((ch0 << 24) + (ch1 << 16) + (ch2 << 8) + (ch3));
+ }
+
+ public void seek(long position) throws java.io.IOException{
+ access.seek(name,key,position);
+ }
+
+ public void write(byte[] b, int offset, int length) throws java.io.IOException{
+ access.write(name,key,b,offset,length);
+ }
+
+ public void writeInt(int v) throws java.io.IOException{
+ byte [] oneByte = new byte [4];
+ oneByte[0] = (byte) ((v >>> 24) & 0xFF);
+ oneByte[1] = (byte) ((v >>> 16) & 0xFF);
+ oneByte[2] = (byte) ((v >>> 8) & 0xFF);
+ oneByte[3] = (byte) ((v >>> 0) & 0xFF);
+
+ write(oneByte,0,4);
+ }
+
+ public boolean isReadOnly() {
+ return readonly;
+ }
+
+ @SuppressWarnings("cast")
+ public long readLong() throws java.io.IOException {
+ return (((long) readInt()) << 32) + (((long) readInt()) & 0xFFFFFFFFL);
+ }
+
+ public boolean wasNio() {
+ return false;
+ }
+
+ public void writeLong(long v) throws java.io.IOException {
+ byte [] oneByte = new byte [8];
+
+ oneByte[0] = (byte) ((v >>> 56) & 0xFF);
+ oneByte[1] = (byte) ((v >>> 48) & 0xFF);
+ oneByte[2] = (byte) ((v >>> 40) & 0xFF);
+ oneByte[3] = (byte) ((v >>> 32) & 0xFF);
+ oneByte[4] = (byte) ((v >>> 24) & 0xFF);
+ oneByte[5] = (byte) ((v >>> 16) & 0xFF);
+ oneByte[6] = (byte) ((v >>> 8) & 0xFF);
+ oneByte[7] = (byte) ((v >>> 0) & 0xFF);
+
+ write(oneByte,0,8);
+ }
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java
new file mode 100644
index 000000000000..0dd640c4ec57
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java
@@ -0,0 +1,90 @@
+/*
+ * 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 .
+ */
+package com.sun.star.sdbcx.comp.hsqldb;
+
+import org.hsqldb.lib.FileAccess;
+import org.hsqldb.lib.FileSystemRuntimeException;
+
+@SuppressWarnings("ucd")
+public class StorageFileAccess implements org.hsqldb.lib.FileAccess{
+ static { NativeLibraries.load(); }
+
+ String ds_name;
+ String key;
+ /** Creates a new instance of StorageFileAccess */
+ public StorageFileAccess(Object key) throws java.lang.Exception{
+ this.key = (String)key;
+ }
+
+ public void createParentDirs(String filename) {
+ }
+
+ public boolean isStreamElement(String elementName) {
+ return isStreamElement(key,elementName);
+ }
+
+ public java.io.InputStream openInputStreamElement(String streamName) throws java.io.IOException {
+ return new NativeInputStreamHelper(key,streamName);
+ }
+
+ public java.io.OutputStream openOutputStreamElement(String streamName) throws java.io.IOException {
+ return new NativeOutputStreamHelper(key,streamName);
+ }
+
+ public void removeElement(String filename) throws java.util.NoSuchElementException {
+ try {
+ if ( isStreamElement(key,filename) )
+ removeElement(key,filename);
+ } catch (java.io.IOException e) {
+ throw new FileSystemRuntimeException( e );
+ }
+ }
+
+ public void renameElement(String oldName, String newName) throws java.util.NoSuchElementException {
+ try {
+ if ( isStreamElement(key,oldName) ){
+ removeElement(key,newName);
+ renameElement(key,oldName, newName);
+ }
+ } catch (java.io.IOException e) {
+ throw new FileSystemRuntimeException( e );
+ }
+ }
+
+ private static class FileSync implements FileAccess.FileSync
+ {
+ private final NativeOutputStreamHelper os;
+ private FileSync(NativeOutputStreamHelper _os)
+ {
+ os = _os;
+ }
+ public void sync() throws java.io.IOException
+ {
+ os.sync();
+ }
+ }
+
+ public FileAccess.FileSync getFileSync(java.io.OutputStream os) throws java.io.IOException
+ {
+ return new FileSync((NativeOutputStreamHelper)os);
+ }
+
+ static native boolean isStreamElement(String key,String elementName);
+ static native void removeElement(String key,String filename) throws java.util.NoSuchElementException, java.io.IOException;
+ static native void renameElement(String key,String oldName, String newName) throws java.util.NoSuchElementException, java.io.IOException;
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java
new file mode 100644
index 000000000000..cf147c9b5005
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java
@@ -0,0 +1,34 @@
+/*
+ * 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 .
+ */
+package com.sun.star.sdbcx.comp.hsqldb;
+
+public class StorageNativeInputStream {
+ static { NativeLibraries.load(); }
+
+ /** Creates a new instance of StorageNativeInputStream */
+ public StorageNativeInputStream(String key,String _file) {
+ openStream(key,_file, NativeStorageAccess.READ);
+ }
+ private native void openStream(String key,String name, int mode);
+ public native int read(String key,String name) throws java.io.IOException;
+ public native int read(String key,String name,byte[] b, int off, int len) throws java.io.IOException;
+ public native void close(String key,String name) throws java.io.IOException;
+ public native long skip(String key,String name,long n) throws java.io.IOException;
+ public native int available(String key,String name) throws java.io.IOException;
+ public native int read(String key,String name,byte[] b) throws java.io.IOException;
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java
new file mode 100644
index 000000000000..8cc6cb07d353
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java
@@ -0,0 +1,145 @@
+/*
+ * 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 .
+ */
+package com.sun.star.sdbcx.comp.hsqldb;
+
+public class StorageNativeOutputStream {
+ static { NativeLibraries.load(); }
+
+ /** Creates a new instance of StorageNativeOutputStream */
+ public StorageNativeOutputStream(String _name, Object key) {
+ openStream(_name, (String)key, NativeStorageAccess.WRITE | NativeStorageAccess.TRUNCATE);
+ }
+
+ private native void openStream(String name,String key, int mode);
+ /**
+ * Writes len
bytes from the specified byte array
+ * starting at offset off
to this output stream.
+ * The general contract for write(b, off, len)
is that
+ * some of the bytes in the array b
are written to the
+ * output stream in order; element b[off]
is the first
+ * byte written and b[off+len-1]
is the last byte written
+ * by this operation.
+ *
+ * The write
method of OutputStream
calls
+ * the write method of one argument on each of the bytes to be
+ * written out. Subclasses are encouraged to override this method and
+ * provide a more efficient implementation.
+ *
+ * If b
is null
, a
+ * NullPointerException
is thrown.
+ *
+ * If off
is negative, or len
is negative, or
+ * off+len
is greater than the length of the array
+ * b
, then an IndexOutOfBoundsException is thrown.
+ * @param key The name of the data source.
+ * @param _file The name of the file to write to.
+ * @param b the data.
+ * @param off the start offset in the data.
+ * @param len the number of bytes to write.
+ * @exception java.io.IOException if an I/O error occurs. In particular,
+ * an IOException
is thrown if the output
+ * stream is closed.
+ */
+ public native void write(String key,String _file,byte[] b, int off, int len) throws java.io.IOException;
+
+ /**
+ * Writes b.length
bytes from the specified byte array
+ * to this output stream. The general contract for write(b)
+ * is that it should have exactly the same effect as the call
+ * write(b, 0, b.length)
.
+ *
+ * @param b the data.
+ * @exception java.io.IOException if an I/O error occurs.
+ * @see java.io.OutputStream#write(byte[], int, int)
+ */
+ public native void write(String key,String _file,byte[] b) throws java.io.IOException;
+
+ /**
+ * Closes this output stream and releases any system resources
+ * associated with this stream. The general contract of close
+ * is that it closes the output stream. A closed stream cannot perform
+ * output operations and cannot be reopened.
+ *
+ * The close
method of OutputStream
does nothing.
+ * @param key The name of the data source.
+ * @param _file The name of the file to write to.
+ *
+ * @exception java.io.IOException if an I/O error occurs.
+ */
+ public native void close(String key,String _file) throws java.io.IOException;
+
+ /**
+ * Writes the specified byte to this output stream. The general
+ * contract for write
is that one byte is written
+ * to the output stream. The byte to be written is the eight
+ * low-order bits of the argument b
. The 24
+ * high-order bits of b
are ignored.
+ *
+ * Subclasses of OutputStream
must provide an
+ * implementation for this method.
+ *
+ * @param key The name of the data source.
+ * @param _file The name of the file to write to.
+ * @param b the byte
.
+ * @exception java.io.IOException if an I/O error occurs. In particular,
+ * an IOException
may be thrown if the
+ * output stream has been closed.
+ */
+ public native void write(String key,String _file,int b) throws java.io.IOException;
+
+ /**
+ * Flushes this output stream and forces any buffered output bytes
+ * to be written out. The general contract of flush
is
+ * that calling it is an indication that, if any bytes previously
+ * written have been buffered by the implementation of the output
+ * stream, such bytes should immediately be written to their
+ * intended destination.
+ *
+ * The flush
method of OutputStream
does nothing.
+ * @param key The name of the data source.
+ * @param _file The name of the file to write to.
+ *
+ * @exception java.io.IOException if an I/O error occurs.
+ */
+ public native void flush(String key,String _file) throws java.io.IOException;
+
+ /**
+ * Force all system buffers to synchronize with the underlying
+ * device. This method returns after all modified data and
+ * attributes have been written to the relevant device(s).
+ *
+ * sync is meant to be used by code that requires physical
+ * storage (such as a file) to be in a known state For
+ * example, a class that provided a simple transaction facility
+ * might use sync to ensure that all changes to a file caused
+ * by a given transaction were recorded on a storage medium.
+ *
+ * sync only affects buffers downstream. If
+ * any in-memory buffering is being done by the application (for
+ * example, by a BufferedOutputStream object), those buffers must
+ * be flushed (for example, by invoking
+ * OutputStream.flush) before that data will be affected by sync.
+ *
+ * @exception java.io.IOException
+ * Thrown when the buffers cannot be flushed,
+ * or because the system cannot guarantee that all the
+ * buffers have been synchronized with physical media.
+ */
+ public native void sync(String key,String _file) throws java.io.IOException;
+
+}
diff --git a/connectivity/registry/hsqldb/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/hsqldb/org/openoffice/Office/DataAccess/Drivers.xcu
new file mode 100644
index 000000000000..59dc5b86ea21
--- /dev/null
+++ b/connectivity/registry/hsqldb/org/openoffice/Office/DataAccess/Drivers.xcu
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+ com.sun.star.sdbcx.comp.hsqldb.Driver
+
+
+ HSQLDB Embedded
+
+
+
+
+ true
+
+
+
+
+ true
+
+
+
+
+ true
+
+
+
+
+ false
+
+
+
+
+ true
+
+
+
+
+
+
+ true
+
+
+
+
+ true
+
+
+
+
+ true
+
+
+
+
+
+
diff --git a/connectivity/source/commontools/DriversConfig.cxx b/connectivity/source/commontools/DriversConfig.cxx
index 29f5b22de880..a6b78b0d0330 100644
--- a/connectivity/source/commontools/DriversConfig.cxx
+++ b/connectivity/source/commontools/DriversConfig.cxx
@@ -76,7 +76,6 @@ namespace
OUString sDriverTypeDisplayName;
aURLPatternNode.getNodeValue("DriverTypeDisplayName") >>= sDriverTypeDisplayName;
-
OSL_ENSURE(!sDriverTypeDisplayName.isEmpty(),"No valid DriverTypeDisplayName property!");
if ( !sDriverTypeDisplayName.isEmpty() )
_rInstalledDriver.sDriverTypeDisplayName = sDriverTypeDisplayName;
@@ -113,7 +112,9 @@ const TInstalledDrivers& DriversConfigImpl::getInstalledDrivers(const uno::Refer
{
TInstalledDriver aInstalledDriver;
lcl_readURLPatternNode(m_aInstalled,*pPatternIter,aInstalledDriver);
- if ( !aInstalledDriver.sDriverFactory.isEmpty() )
+ if ( !aInstalledDriver.sDriverFactory.isEmpty() &&
+ ( aMiscOptions.IsExperimentalMode() ||
+ aInstalledDriver.sDriverFactory != "com.sun.star.comp.sdbc.firebird.Driver" ))
m_aDrivers.emplace(*pPatternIter,aInstalledDriver);
}
} // if ( m_aInstalled.isValid() )
diff --git a/connectivity/source/drivers/hsqldb/HCatalog.cxx b/connectivity/source/drivers/hsqldb/HCatalog.cxx
new file mode 100644
index 000000000000..9824ead35dc8
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HCatalog.cxx
@@ -0,0 +1,150 @@
+/* -*- 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
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+using namespace connectivity;
+using namespace connectivity::hsqldb;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+OHCatalog::OHCatalog(const Reference< XConnection >& _xConnection) : sdbcx::OCatalog(_xConnection)
+ ,m_xConnection(_xConnection)
+{
+}
+
+void OHCatalog::refreshObjects(const Sequence< OUString >& _sKindOfObject,::std::vector< OUString>& _rNames)
+{
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
+ "%",
+ "%",
+ _sKindOfObject);
+ fillNames(xResult,_rNames);
+}
+
+void OHCatalog::refreshTables()
+{
+ ::std::vector< OUString> aVector;
+
+ Sequence< OUString > sTableTypes(2);
+ sTableTypes[0] = "VIEW";
+ sTableTypes[1] = "TABLE";
+
+ refreshObjects(sTableTypes,aVector);
+
+ if ( m_pTables )
+ m_pTables->reFill(aVector);
+ else
+ m_pTables.reset( new OTables(m_xMetaData,*this,m_aMutex,aVector) );
+}
+
+void OHCatalog::refreshViews()
+{
+ Sequence< OUString > aTypes { "VIEW" };
+
+ bool bSupportsViews = false;
+ try
+ {
+ Reference xRes = m_xMetaData->getTableTypes();
+ Reference xRow(xRes,UNO_QUERY);
+ while ( xRow.is() && xRes->next() )
+ {
+ if ( (bSupportsViews = xRow->getString(1).equalsIgnoreAsciiCase(aTypes[0])) )
+ {
+ break;
+ }
+ }
+ }
+ catch(const SQLException&)
+ {
+ }
+
+ ::std::vector< OUString> aVector;
+ if ( bSupportsViews )
+ refreshObjects(aTypes,aVector);
+
+ if ( m_pViews )
+ m_pViews->reFill(aVector);
+ else
+ m_pViews.reset( new HViews( m_xConnection, *this, m_aMutex, aVector ) );
+}
+
+void OHCatalog::refreshGroups()
+{
+}
+
+void OHCatalog::refreshUsers()
+{
+ ::std::vector< OUString> aVector;
+ Reference< XStatement > xStmt = m_xConnection->createStatement( );
+ Reference< XResultSet > xResult = xStmt->executeQuery("select User from hsqldb.user group by User");
+ if ( xResult.is() )
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while( xResult->next() )
+ aVector.push_back(xRow->getString(1));
+ ::comphelper::disposeComponent(xResult);
+ }
+ ::comphelper::disposeComponent(xStmt);
+
+ if(m_pUsers)
+ m_pUsers->reFill(aVector);
+ else
+ m_pUsers.reset( new OUsers(*this,m_aMutex,aVector,m_xConnection,this) );
+}
+
+Any SAL_CALL OHCatalog::queryInterface( const Type & rType )
+{
+ if ( rType == cppu::UnoType::get())
+ return Any();
+
+ return OCatalog::queryInterface(rType);
+}
+
+Sequence< Type > SAL_CALL OHCatalog::getTypes( )
+{
+ Sequence< Type > aTypes = OCatalog::getTypes();
+ std::vector aOwnTypes;
+ aOwnTypes.reserve(aTypes.getLength());
+ const Type* pBegin = aTypes.getConstArray();
+ const Type* pEnd = pBegin + aTypes.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if ( !(*pBegin == cppu::UnoType::get()))
+ {
+ aOwnTypes.push_back(*pBegin);
+ }
+ }
+ return Sequence< Type >(aOwnTypes.data(), aOwnTypes.size());
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/HColumns.cxx b/connectivity/source/drivers/hsqldb/HColumns.cxx
new file mode 100644
index 000000000000..da9b8bbd442b
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HColumns.cxx
@@ -0,0 +1,78 @@
+/* -*- 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
+#include
+
+
+using namespace ::comphelper;
+using namespace connectivity::hsqldb;
+using namespace connectivity::sdbcx;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+OHSQLColumns::OHSQLColumns( ::cppu::OWeakObject& _rParent
+ ,::osl::Mutex& _rMutex
+ ,const ::std::vector< OUString> &_rVector
+ ) : OColumnsHelper(_rParent,true/*_bCase*/,_rMutex,_rVector,true/*_bUseHardRef*/)
+{
+}
+
+Reference< XPropertySet > OHSQLColumns::createDescriptor()
+{
+ return new OHSQLColumn;
+}
+
+
+OHSQLColumn::OHSQLColumn()
+ : connectivity::sdbcx::OColumn( true/*_bCase*/ )
+{
+ construct();
+}
+
+void OHSQLColumn::construct()
+{
+ m_sAutoIncrement = "IDENTITY";
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_AUTOINCREMENTCREATION),PROPERTY_ID_AUTOINCREMENTCREATION,0,&m_sAutoIncrement, cppu::UnoType::get());
+}
+
+::cppu::IPropertyArrayHelper* OHSQLColumn::createArrayHelper( sal_Int32 /*_nId*/ ) const
+{
+ return doCreateArrayHelper();
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL OHSQLColumn::getInfoHelper()
+{
+ return *OHSQLColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
+}
+
+Sequence< OUString > SAL_CALL OHSQLColumn::getSupportedServiceNames( )
+{
+ Sequence< OUString > aSupported { "com.sun.star.sdbcx.Column" };
+
+ return aSupported;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/HStorageMap.cxx b/connectivity/source/drivers/hsqldb/HStorageMap.cxx
new file mode 100644
index 000000000000..ff5df7b01fe3
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HStorageMap.cxx
@@ -0,0 +1,367 @@
+/* -*- 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
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace connectivity
+{
+
+ namespace hsqldb
+ {
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::embed;
+ using namespace ::com::sun::star::io;
+
+ StreamHelper::StreamHelper(const Reference< XStream>& _xStream)
+ : m_xStream(_xStream)
+ {
+ }
+
+ StreamHelper::~StreamHelper()
+ {
+ try
+ {
+ m_xStream.clear();
+ m_xSeek.clear();
+ if ( m_xInputStream.is() )
+ {
+ m_xInputStream->closeInput();
+ m_xInputStream.clear();
+ }
+ // this is done implicitly by the closing of the input stream
+ else if ( m_xOutputStream.is() )
+ {
+ m_xOutputStream->closeOutput();
+ try
+ {
+ ::comphelper::disposeComponent(m_xOutputStream);
+ }
+ catch(const DisposedException&)
+ {
+ }
+ catch(const Exception&)
+ {
+ OSL_FAIL("Could not dispose OutputStream");
+ }
+ m_xOutputStream.clear();
+ }
+ }
+ catch(const Exception&)
+ {
+ OSL_FAIL("Exception caught!");
+ }
+ }
+
+ Reference< XInputStream> const & StreamHelper::getInputStream()
+ {
+ if ( !m_xInputStream.is() )
+ m_xInputStream = m_xStream->getInputStream();
+ return m_xInputStream;
+ }
+
+ Reference< XOutputStream> const & StreamHelper::getOutputStream()
+ {
+ if ( !m_xOutputStream.is() )
+ m_xOutputStream = m_xStream->getOutputStream();
+ return m_xOutputStream;
+ }
+
+ Reference< XSeekable> const & StreamHelper::getSeek()
+ {
+ if ( !m_xSeek.is() )
+ m_xSeek.set(m_xStream,UNO_QUERY);
+ return m_xSeek;
+ }
+
+ css::uno::Reference StorageData::mapStorage()
+ const
+ {
+ css::uno::Environment env(css::uno::Environment::getCurrent());
+ if (!(env.is() && storageEnvironment.is())) {
+ throw css::uno::RuntimeException("cannot get environments");
+ }
+ if (env.get() == storageEnvironment.get()) {
+ return storage;
+ } else {
+ css::uno::Mapping map(storageEnvironment, env);
+ if (!map.is()) {
+ throw css::uno::RuntimeException("cannot get mapping");
+ }
+ css::uno::Reference mapped;
+ map.mapInterface(
+ reinterpret_cast(&mapped), storage.get(),
+ cppu::UnoType::get());
+ return mapped;
+ }
+ }
+
+ TStorages& lcl_getStorageMap()
+ {
+ static TStorages s_aMap;
+ return s_aMap;
+ }
+
+ OUString lcl_getNextCount()
+ {
+ static sal_Int32 s_nCount = 0;
+ return OUString::number(s_nCount++);
+ }
+
+ OUString StorageContainer::removeURLPrefix(const OUString& _sURL,const OUString& _sFileURL)
+ {
+ return _sURL.copy(_sFileURL.getLength()+1);
+ }
+
+ OUString StorageContainer::removeOldURLPrefix(const OUString& _sURL)
+ {
+ OUString sRet = _sURL;
+#if defined(_WIN32)
+ sal_Int32 nIndex = sRet.lastIndexOf('\\');
+#else
+ sal_Int32 nIndex = sRet.lastIndexOf('/');
+#endif
+ if ( nIndex != -1 )
+ {
+ sRet = _sURL.copy(nIndex+1);
+ }
+ return sRet;
+
+ }
+ /*****************************************************************************/
+ /* convert jstring to rtl_uString */
+
+ OUString StorageContainer::jstring2ustring(JNIEnv * env, jstring jstr)
+ {
+ if (env->ExceptionCheck())
+ {
+ env->ExceptionClear();
+ OSL_FAIL("ExceptionClear");
+ }
+ OUString aStr;
+ if ( jstr )
+ {
+ jboolean bCopy(true);
+ const jchar* pChar = env->GetStringChars(jstr,&bCopy);
+ jsize len = env->GetStringLength(jstr);
+ aStr = OUString(
+ reinterpret_cast(pChar), len);
+
+ if(bCopy)
+ env->ReleaseStringChars(jstr,pChar);
+ }
+
+ if (env->ExceptionCheck())
+ {
+ env->ExceptionClear();
+ OSL_FAIL("ExceptionClear");
+ }
+ return aStr;
+ }
+
+
+ OUString StorageContainer::registerStorage(const Reference< XStorage>& _xStorage,const OUString& _sURL)
+ {
+ OSL_ENSURE(_xStorage.is(),"Storage is NULL!");
+ TStorages& rMap = lcl_getStorageMap();
+ // check if the storage is already in our map
+ TStorages::const_iterator aFind = std::find_if(rMap.begin(),rMap.end(),
+ [&_xStorage] (const TStorages::value_type& storage) {
+ return storage.second.mapStorage() == _xStorage;
+ });
+
+ if ( aFind == rMap.end() )
+ {
+ aFind = rMap.insert(TStorages::value_type(lcl_getNextCount(), {_xStorage, css::uno::Environment::getCurrent(), _sURL, TStreamMap()})).first;
+ }
+
+ return aFind->first;
+ }
+
+ TStorages::mapped_type StorageContainer::getRegisteredStorage(const OUString& _sKey)
+ {
+ TStorages::mapped_type aRet;
+ TStorages& rMap = lcl_getStorageMap();
+ TStorages::const_iterator aFind = rMap.find(_sKey);
+ OSL_ENSURE(aFind != rMap.end(),"Storage could not be found in list!");
+ if ( aFind != rMap.end() )
+ aRet = aFind->second;
+
+ return aRet;
+ }
+
+ OUString StorageContainer::getRegisteredKey(const Reference< XStorage>& _xStorage)
+ {
+ OUString sKey;
+ OSL_ENSURE(_xStorage.is(),"Storage is NULL!");
+ TStorages& rMap = lcl_getStorageMap();
+ // check if the storage is already in our map
+ TStorages::const_iterator aFind = std::find_if(rMap.begin(),rMap.end(),
+ [&_xStorage] (const TStorages::value_type& storage) {
+ return storage.second.mapStorage() == _xStorage;
+ });
+
+ if ( aFind != rMap.end() )
+ sKey = aFind->first;
+ return sKey;
+ }
+
+ void StorageContainer::revokeStorage(const OUString& _sKey,const Reference& _xListener)
+ {
+ TStorages& rMap = lcl_getStorageMap();
+ TStorages::iterator aFind = rMap.find(_sKey);
+ if ( aFind != rMap.end() )
+ {
+ try
+ {
+ if ( _xListener.is() )
+ {
+ Reference xBroad(aFind->second.mapStorage(),UNO_QUERY);
+ if ( xBroad.is() )
+ xBroad->removeTransactionListener(_xListener);
+ Reference xTrans(aFind->second.mapStorage(),UNO_QUERY);
+ if ( xTrans.is() )
+ xTrans->commit();
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+ rMap.erase(aFind);
+ }
+ }
+
+ TStreamMap::mapped_type StorageContainer::registerStream(JNIEnv * env,jstring name, jstring key,sal_Int32 _nMode)
+ {
+ TStreamMap::mapped_type pHelper;
+ TStorages& rMap = lcl_getStorageMap();
+ OUString sKey = jstring2ustring(env,key);
+ TStorages::iterator aFind = rMap.find(sKey);
+ OSL_ENSURE(aFind != rMap.end(),"Storage could not be found in list!");
+ if ( aFind != rMap.end() )
+ {
+ TStorages::mapped_type aStoragePair = StorageContainer::getRegisteredStorage(sKey);
+ auto storage = aStoragePair.mapStorage();
+ OSL_ENSURE(storage.is(),"No Storage available!");
+ if ( storage.is() )
+ {
+ OUString sOrgName = StorageContainer::jstring2ustring(env,name);
+ OUString sName = removeURLPrefix(sOrgName,aStoragePair.url);
+ TStreamMap::iterator aStreamFind = aFind->second.streams.find(sName);
+ OSL_ENSURE( aStreamFind == aFind->second.streams.end(),"A Stream was already registered for this object!");
+ if ( aStreamFind != aFind->second.streams.end() )
+ {
+ pHelper = aStreamFind->second;
+ }
+ else
+ {
+ try
+ {
+ try
+ {
+ pHelper.reset(new StreamHelper(storage->openStreamElement(sName,_nMode)));
+ }
+ catch(const Exception&)
+ {
+ OUString sStrippedName = removeOldURLPrefix(sOrgName);
+
+ if ( (_nMode & ElementModes::WRITE) != ElementModes::WRITE )
+ {
+ bool bIsStream = true;
+ try
+ {
+ bIsStream = storage->isStreamElement(sStrippedName);
+ }
+ catch(const Exception&)
+ {
+ bIsStream = false;
+ }
+ if ( !bIsStream )
+ return pHelper; // readonly file without data stream
+ }
+ pHelper.reset( new StreamHelper(storage->openStreamElement( sStrippedName, _nMode ) ) );
+ }
+ aFind->second.streams.emplace(sName,pHelper);
+ }
+ catch(const Exception& e)
+ {
+ SAL_WARN( "connectivity.hsqldb", "[HSQLDB-SDBC] caught an exception while opening a stream\n"
+ "Name: " << sName
+ << "\nMode: 0x" << ( _nMode < 16 ? "0" : "")
+ << std::hex << _nMode );
+ StorageContainer::throwJavaException(e,env);
+ }
+ }
+ }
+ }
+ return pHelper;
+ }
+
+ void StorageContainer::revokeStream( JNIEnv * env,jstring name, jstring key)
+ {
+ TStorages& rMap = lcl_getStorageMap();
+ TStorages::iterator aFind = rMap.find(jstring2ustring(env,key));
+ OSL_ENSURE(aFind != rMap.end(),"Storage could not be found in list!");
+ if ( aFind != rMap.end() )
+ aFind->second.streams.erase(removeURLPrefix(jstring2ustring(env,name),aFind->second.url));
+ }
+
+ TStreamMap::mapped_type StorageContainer::getRegisteredStream( JNIEnv * env,jstring name, jstring key)
+ {
+ TStreamMap::mapped_type pRet;
+ TStorages& rMap = lcl_getStorageMap();
+ TStorages::const_iterator aFind = rMap.find(jstring2ustring(env,key));
+ OSL_ENSURE(aFind != rMap.end(),"Storage could not be found in list!");
+ if ( aFind != rMap.end() )
+ {
+ TStreamMap::const_iterator aStreamFind = aFind->second.streams.find(removeURLPrefix(jstring2ustring(env,name),aFind->second.url));
+ if ( aStreamFind != aFind->second.streams.end() )
+ pRet = aStreamFind->second;
+ }
+
+ return pRet;
+ }
+
+ void StorageContainer::throwJavaException(const Exception& _aException,JNIEnv * env)
+ {
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+ SAL_WARN("connectivity.hsqldb", "forwarding Exception: " << _aException );
+ OString cstr( OUStringToOString(_aException.Message, RTL_TEXTENCODING_JAVA_UTF8 ) );
+ env->ThrowNew(env->FindClass("java/io/IOException"), cstr.getStr());
+ }
+
+ } // namespace hsqldb
+
+
+}
+// namespace connectivity
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/HTables.cxx b/connectivity/source/drivers/hsqldb/HTables.cxx
new file mode 100644
index 000000000000..bde5866b9d92
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HTables.cxx
@@ -0,0 +1,186 @@
+/* -*- 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
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace ::cppu;
+using namespace connectivity::hsqldb;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace dbtools;
+
+sdbcx::ObjectType OTables::createObject(const OUString& _rName)
+{
+ OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(m_xMetaData,_rName,sCatalog,sSchema,sTable,::dbtools::EComposeRule::InDataManipulation);
+
+ Sequence< OUString > sTableTypes(3);
+ sTableTypes[0] = "VIEW";
+ sTableTypes[1] = "TABLE";
+ sTableTypes[2] = "%"; // just to be sure to include anything else ....
+
+ Any aCatalog;
+ if ( !sCatalog.isEmpty() )
+ aCatalog <<= sCatalog;
+ Reference< XResultSet > xResult = m_xMetaData->getTables(aCatalog,sSchema,sTable,sTableTypes);
+
+ sdbcx::ObjectType xRet = nullptr;
+ if ( xResult.is() )
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ if ( xResult->next() ) // there can be only one table with this name
+ {
+ sal_Int32 nPrivileges = ::dbtools::getTablePrivileges( m_xMetaData, sCatalog, sSchema, sTable );
+ if ( m_xMetaData->isReadOnly() )
+ nPrivileges &= ~( Privilege::INSERT | Privilege::UPDATE | Privilege::DELETE | Privilege::CREATE | Privilege::ALTER | Privilege::DROP );
+
+ // obtain privileges
+ OHSQLTable* pRet = new OHSQLTable( this
+ ,static_cast(m_rParent).getConnection()
+ ,sTable
+ ,xRow->getString(4)
+ ,xRow->getString(5)
+ ,sSchema
+ ,sCatalog
+ ,nPrivileges);
+ xRet = pRet;
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+
+ return xRet;
+}
+
+void OTables::impl_refresh( )
+{
+ static_cast(m_rParent).refreshTables();
+}
+
+void OTables::disposing()
+{
+m_xMetaData.clear();
+ OCollection::disposing();
+}
+
+Reference< XPropertySet > OTables::createDescriptor()
+{
+ return new OHSQLTable(this,static_cast(m_rParent).getConnection());
+}
+
+// XAppend
+sdbcx::ObjectType OTables::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ createTable(descriptor);
+ return createObject( _rForName );
+}
+
+// XDrop
+void OTables::dropObject(sal_Int32 _nPos,const OUString& _sElementName)
+{
+ Reference< XInterface > xObject( getObject( _nPos ) );
+ bool bIsNew = connectivity::sdbcx::ODescriptor::isNew( xObject );
+ if (!bIsNew)
+ {
+ Reference< XConnection > xConnection = static_cast(m_rParent).getConnection();
+
+
+ OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(m_xMetaData,_sElementName,sCatalog,sSchema,sTable,::dbtools::EComposeRule::InDataManipulation);
+
+ OUString aSql( "DROP " );
+
+ Reference xProp(xObject,UNO_QUERY);
+ bool bIsView;
+ if((bIsView = (xProp.is() && ::comphelper::getString(xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))) == "VIEW"))) // here we have a view
+ aSql += "VIEW ";
+ else
+ aSql += "TABLE ";
+
+ OUString sComposedName(
+ ::dbtools::composeTableName( m_xMetaData, sCatalog, sSchema, sTable, true, ::dbtools::EComposeRule::InDataManipulation ) );
+ aSql += sComposedName;
+ Reference< XStatement > xStmt = xConnection->createStatement( );
+ if ( xStmt.is() )
+ {
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+ // if no exception was thrown we must delete it from the views
+ if ( bIsView )
+ {
+ HViews* pViews = static_cast(static_cast(m_rParent).getPrivateViews());
+ if ( pViews && pViews->hasByName(_sElementName) )
+ pViews->dropByNameImpl(_sElementName);
+ }
+ }
+}
+
+void OTables::createTable( const Reference< XPropertySet >& descriptor )
+{
+ Reference< XConnection > xConnection = static_cast(m_rParent).getConnection();
+ OUString aSql = ::dbtools::createSqlCreateTableStatement(descriptor,xConnection);
+
+ Reference< XStatement > xStmt = xConnection->createStatement( );
+ if ( xStmt.is() )
+ {
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+
+void OTables::appendNew(const OUString& _rsNewTable)
+{
+ insertElement(_rsNewTable,nullptr);
+
+ // notify our container listeners
+ ContainerEvent aEvent(static_cast(this), makeAny(_rsNewTable), Any(), Any());
+ OInterfaceIteratorHelper2 aListenerLoop(m_aContainerListeners);
+ while (aListenerLoop.hasMoreElements())
+ static_cast(aListenerLoop.next())->elementInserted(aEvent);
+}
+
+OUString OTables::getNameForObject(const sdbcx::ObjectType& _xObject)
+{
+ OSL_ENSURE(_xObject.is(),"OTables::getNameForObject: Object is NULL!");
+ return ::dbtools::composeTableName( m_xMetaData, _xObject, ::dbtools::EComposeRule::InDataManipulation, false );
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/HTerminateListener.cxx b/connectivity/source/drivers/hsqldb/HTerminateListener.cxx
new file mode 100644
index 000000000000..df325efb75e8
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HTerminateListener.cxx
@@ -0,0 +1,52 @@
+/* -*- 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 "HTerminateListener.hxx"
+#include
+
+
+namespace connectivity
+{
+
+ using namespace hsqldb;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+
+// XEventListener
+void SAL_CALL OConnectionController::disposing( const EventObject& /*Source*/ )
+{
+}
+
+// XTerminateListener
+void SAL_CALL OConnectionController::queryTermination( const EventObject& /*aEvent*/ )
+{
+ m_pDriver->flushConnections();
+}
+
+void SAL_CALL OConnectionController::notifyTermination( const EventObject& /*aEvent*/ )
+{
+ m_pDriver->shutdownConnections();
+}
+
+
+} // namespace connectivity
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/HTerminateListener.hxx b/connectivity/source/drivers/hsqldb/HTerminateListener.hxx
new file mode 100644
index 000000000000..62e8ec79d660
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HTerminateListener.hxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_HSQLDB_HTERMINATELISTENER_HXX
+#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_HSQLDB_HTERMINATELISTENER_HXX
+
+#include
+#include
+
+
+namespace connectivity
+{
+
+
+ namespace hsqldb
+ {
+ class ODriverDelegator;
+ class OConnectionController : public ::cppu::WeakImplHelper< css::frame::XTerminateListener >
+ {
+ ODriverDelegator* m_pDriver;
+ protected:
+ virtual ~OConnectionController() override {m_pDriver = nullptr;}
+ public:
+ explicit OConnectionController(ODriverDelegator* _pDriver) : m_pDriver(_pDriver){}
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
+
+ // XTerminateListener
+ virtual void SAL_CALL queryTermination( const css::lang::EventObject& aEvent ) override;
+ virtual void SAL_CALL notifyTermination( const css::lang::EventObject& aEvent ) override;
+ };
+ }
+
+} // namespace connectivity
+
+#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_HSQLDB_HTERMINATELISTENER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/HTools.cxx b/connectivity/source/drivers/hsqldb/HTools.cxx
new file mode 100644
index 000000000000..9a31ace4602b
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HTools.cxx
@@ -0,0 +1,53 @@
+/* -*- 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
+
+
+namespace connectivity { namespace hsqldb
+{
+
+ void HTools::appendTableFilterCrit( OUStringBuffer& _inout_rBuffer, const OUString& _rCatalog,
+ const OUString& _rSchema, const OUString& _rName, bool _bShortForm )
+ {
+ _inout_rBuffer.append( " WHERE " );
+ if ( !_rCatalog.isEmpty() )
+ {
+ _inout_rBuffer.appendAscii( _bShortForm ? "TABLE_CAT" : "TABLE_CATALOG" );
+ _inout_rBuffer.append( " = '" );
+ _inout_rBuffer.append ( _rCatalog );
+ _inout_rBuffer.append( "' AND " );
+ }
+ if ( !_rSchema.isEmpty() )
+ {
+ _inout_rBuffer.appendAscii( _bShortForm ? "TABLE_SCHEM" : "TABLE_SCHEMA" );
+ _inout_rBuffer.append( " = '" );
+ _inout_rBuffer.append ( _rSchema );
+ _inout_rBuffer.append( "' AND " );
+ }
+ _inout_rBuffer.append( "TABLE_NAME = '" );
+ _inout_rBuffer.append ( _rName );
+ _inout_rBuffer.append( "'" );
+ }
+
+
+} } // namespace connectivity::hsqldb
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/HUser.cxx b/connectivity/source/drivers/hsqldb/HUser.cxx
new file mode 100644
index 000000000000..5fd38f739a51
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HUser.cxx
@@ -0,0 +1,327 @@
+/* -*- 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
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace connectivity;
+using namespace connectivity::hsqldb;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+OHSQLUser::OHSQLUser( const css::uno::Reference< css::sdbc::XConnection >& _xConnection) : connectivity::sdbcx::OUser(true)
+ ,m_xConnection(_xConnection)
+{
+ construct();
+}
+
+OHSQLUser::OHSQLUser( const css::uno::Reference< css::sdbc::XConnection >& _xConnection,
+ const OUString& Name
+ ) : connectivity::sdbcx::OUser(Name,true)
+ ,m_xConnection(_xConnection)
+{
+ construct();
+}
+
+void OHSQLUser::refreshGroups()
+{
+}
+
+OUserExtend::OUserExtend( const css::uno::Reference< css::sdbc::XConnection >& _xConnection) : OHSQLUser(_xConnection)
+{
+ construct();
+}
+
+void OUserExtend::construct()
+{
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD), PROPERTY_ID_PASSWORD,0,&m_Password,::cppu::UnoType::get());
+}
+
+cppu::IPropertyArrayHelper* OUserExtend::createArrayHelper() const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new cppu::OPropertyArrayHelper(aProps);
+}
+
+cppu::IPropertyArrayHelper & OUserExtend::getInfoHelper()
+{
+ return *OUserExtend_PROP::getArrayHelper();
+}
+typedef connectivity::sdbcx::OUser_BASE OUser_BASE_RBHELPER;
+
+sal_Int32 SAL_CALL OHSQLUser::getPrivileges( const OUString& objName, sal_Int32 objType )
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+
+ sal_Int32 nRights,nRightsWithGrant;
+ findPrivilegesAndGrantPrivileges(objName,objType,nRights,nRightsWithGrant);
+ return nRights;
+}
+
+void OHSQLUser::findPrivilegesAndGrantPrivileges(const OUString& objName, sal_Int32 objType,sal_Int32& nRights,sal_Int32& nRightsWithGrant)
+{
+ nRightsWithGrant = nRights = 0;
+ // first we need to create the sql stmt to select the privs
+ Reference xMeta = m_xConnection->getMetaData();
+ OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(xMeta,objName,sCatalog,sSchema,sTable,::dbtools::EComposeRule::InDataManipulation);
+ Reference xRes;
+ switch(objType)
+ {
+ case PrivilegeObject::TABLE:
+ case PrivilegeObject::VIEW:
+ {
+ Any aCatalog;
+ if ( !sCatalog.isEmpty() )
+ aCatalog <<= sCatalog;
+ xRes = xMeta->getTablePrivileges(aCatalog,sSchema,sTable);
+ }
+ break;
+
+ case PrivilegeObject::COLUMN:
+ {
+ Any aCatalog;
+ if ( !sCatalog.isEmpty() )
+ aCatalog <<= sCatalog;
+ xRes = xMeta->getColumnPrivileges(aCatalog,sSchema,sTable,"%");
+ }
+ break;
+ }
+
+ if ( xRes.is() )
+ {
+ static const char sYes [] = "YES";
+
+ nRightsWithGrant = nRights = 0;
+
+ Reference xCurrentRow(xRes,UNO_QUERY);
+ while( xCurrentRow.is() && xRes->next() )
+ {
+ OUString sGrantee = xCurrentRow->getString(5);
+ OUString sPrivilege = xCurrentRow->getString(6);
+ OUString sGrantable = xCurrentRow->getString(7);
+
+ if (!m_Name.equalsIgnoreAsciiCase(sGrantee))
+ continue;
+
+ if (sPrivilege.equalsIgnoreAsciiCase("SELECT"))
+ {
+ nRights |= Privilege::SELECT;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::SELECT;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase("INSERT"))
+ {
+ nRights |= Privilege::INSERT;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::INSERT;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase("UPDATE"))
+ {
+ nRights |= Privilege::UPDATE;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::UPDATE;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase("DELETE"))
+ {
+ nRights |= Privilege::DELETE;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::DELETE;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase("READ"))
+ {
+ nRights |= Privilege::READ;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::READ;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase("CREATE"))
+ {
+ nRights |= Privilege::CREATE;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::CREATE;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase("ALTER"))
+ {
+ nRights |= Privilege::ALTER;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::ALTER;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase("REFERENCE"))
+ {
+ nRights |= Privilege::REFERENCE;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::REFERENCE;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase("DROP"))
+ {
+ nRights |= Privilege::DROP;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::DROP;
+ }
+ }
+ ::comphelper::disposeComponent(xRes);
+ }
+}
+
+sal_Int32 SAL_CALL OHSQLUser::getGrantablePrivileges( const OUString& objName, sal_Int32 objType )
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+
+ sal_Int32 nRights,nRightsWithGrant;
+ findPrivilegesAndGrantPrivileges(objName,objType,nRights,nRightsWithGrant);
+ return nRightsWithGrant;
+}
+
+void SAL_CALL OHSQLUser::grantPrivileges( const OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges )
+{
+ if ( objType != PrivilegeObject::TABLE )
+ {
+ ::connectivity::SharedResources aResources;
+ const OUString sError( aResources.getResourceString(STR_PRIVILEGE_NOT_GRANTED));
+ ::dbtools::throwGenericSQLException(sError,*this);
+ } // if ( objType != PrivilegeObject::TABLE )
+
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ OUString sPrivs = getPrivilegeString(objPrivileges);
+ if(!sPrivs.isEmpty())
+ {
+ Reference xMeta = m_xConnection->getMetaData();
+ OUString sGrant = "GRANT " + sPrivs +
+ " ON " + ::dbtools::quoteTableName(xMeta,objName,::dbtools::EComposeRule::InDataManipulation) +
+ " TO " + ::dbtools::quoteName(xMeta->getIdentifierQuoteString(), m_Name);
+
+ Reference xStmt = m_xConnection->createStatement();
+ if(xStmt.is())
+ xStmt->execute(sGrant);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+
+void SAL_CALL OHSQLUser::revokePrivileges( const OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges )
+{
+ if ( objType != PrivilegeObject::TABLE )
+ {
+ ::connectivity::SharedResources aResources;
+ const OUString sError( aResources.getResourceString(STR_PRIVILEGE_NOT_REVOKED));
+ ::dbtools::throwGenericSQLException(sError,*this);
+ } // if ( objType != PrivilegeObject::TABLE )
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+ OUString sPrivs = getPrivilegeString(objPrivileges);
+ if(!sPrivs.isEmpty())
+ {
+ Reference xMeta = m_xConnection->getMetaData();
+ OUString sGrant = "REVOKE " + sPrivs +
+ " ON " + ::dbtools::quoteTableName(xMeta,objName,::dbtools::EComposeRule::InDataManipulation) +
+ " FROM " + ::dbtools::quoteName(xMeta->getIdentifierQuoteString(), m_Name);
+
+ Reference xStmt = m_xConnection->createStatement();
+ if(xStmt.is())
+ xStmt->execute(sGrant);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+
+// XUser
+void SAL_CALL OHSQLUser::changePassword( const OUString& /*oldPassword*/, const OUString& newPassword )
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+
+ Reference xMeta = m_xConnection->getMetaData();
+
+ if( m_Name != xMeta->getUserName() )
+ {
+ ::dbtools::throwGenericSQLException("HSQLDB can only change password of the current user.", *this);
+ }
+
+ OUString sAlterPwd = "SET PASSWORD " +
+ ::dbtools::quoteName(xMeta->getIdentifierQuoteString(), newPassword);
+
+ Reference xStmt = m_xConnection->createStatement();
+ if ( xStmt.is() )
+ {
+ xStmt->execute(sAlterPwd);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+
+OUString OHSQLUser::getPrivilegeString(sal_Int32 nRights)
+{
+ OUString sPrivs;
+ if((nRights & Privilege::INSERT) == Privilege::INSERT)
+ sPrivs += "INSERT";
+
+ if((nRights & Privilege::DELETE) == Privilege::DELETE)
+ {
+ if(!sPrivs.isEmpty())
+ sPrivs += ",";
+ sPrivs += "DELETE";
+ }
+
+ if((nRights & Privilege::UPDATE) == Privilege::UPDATE)
+ {
+ if(!sPrivs.isEmpty())
+ sPrivs += ",";
+ sPrivs += "UPDATE";
+ }
+
+ if((nRights & Privilege::ALTER) == Privilege::ALTER)
+ {
+ if(!sPrivs.isEmpty())
+ sPrivs += ",";
+ sPrivs += "ALTER";
+ }
+
+ if((nRights & Privilege::SELECT) == Privilege::SELECT)
+ {
+ if(!sPrivs.isEmpty())
+ sPrivs += ",";
+ sPrivs += "SELECT";
+ }
+
+ if((nRights & Privilege::REFERENCE) == Privilege::REFERENCE)
+ {
+ if(!sPrivs.isEmpty())
+ sPrivs += ",";
+ sPrivs += "REFERENCES";
+ }
+
+ return sPrivs;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/HUsers.cxx b/connectivity/source/drivers/hsqldb/HUsers.cxx
new file mode 100644
index 000000000000..c6992c9328c3
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HUsers.cxx
@@ -0,0 +1,103 @@
+/* -*- 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
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::hsqldb;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+OUsers::OUsers( ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const ::std::vector< OUString> &_rVector,
+ const css::uno::Reference< css::sdbc::XConnection >& _xConnection,
+ connectivity::sdbcx::IRefreshableUsers* _pParent)
+ : sdbcx::OCollection(_rParent, true, _rMutex, _rVector)
+ ,m_xConnection(_xConnection)
+ ,m_pParent(_pParent)
+{
+}
+
+
+sdbcx::ObjectType OUsers::createObject(const OUString& _rName)
+{
+ return new OHSQLUser(m_xConnection,_rName);
+}
+
+void OUsers::impl_refresh()
+{
+ m_pParent->refreshUsers();
+}
+
+Reference< XPropertySet > OUsers::createDescriptor()
+{
+ OUserExtend* pNew = new OUserExtend(m_xConnection);
+ return pNew;
+}
+
+// XAppend
+sdbcx::ObjectType OUsers::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ OUString aQuote = m_xConnection->getMetaData()->getIdentifierQuoteString( );
+ OUString sPassword;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)) >>= sPassword;
+ OUString aSql = "GRANT USAGE ON * TO " +
+ ::dbtools::quoteName(aQuote,_rForName) + " @\"%\" ";
+ if ( !sPassword.isEmpty() )
+ {
+ aSql += " IDENTIFIED BY '" + sPassword + "'";
+ }
+
+ Reference< XStatement > xStmt = m_xConnection->createStatement( );
+ if(xStmt.is())
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+
+ return createObject( _rForName );
+}
+
+// XDrop
+void OUsers::dropObject(sal_Int32 /*nPos*/,const OUString& _sElementName)
+{
+ OUString aSql( "REVOKE ALL ON * FROM " );
+ OUString aQuote = m_xConnection->getMetaData()->getIdentifierQuoteString( );
+ aSql += ::dbtools::quoteName(aQuote,_sElementName);
+
+ Reference< XStatement > xStmt = m_xConnection->createStatement( );
+ if(xStmt.is())
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/HViews.cxx b/connectivity/source/drivers/hsqldb/HViews.cxx
new file mode 100644
index 000000000000..c66d869e09a4
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HViews.cxx
@@ -0,0 +1,158 @@
+/* -*- 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
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace ::comphelper;
+
+using namespace ::cppu;
+using namespace connectivity;
+using namespace connectivity::hsqldb;
+using namespace css::uno;
+using namespace css::beans;
+using namespace css::sdbcx;
+using namespace css::sdbc;
+using namespace css::container;
+using namespace css::lang;
+using namespace dbtools;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+
+HViews::HViews( const Reference< XConnection >& _rxConnection, ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex,
+ const ::std::vector< OUString> &_rVector )
+ :sdbcx::OCollection( _rParent, true, _rMutex, _rVector )
+ ,m_xConnection( _rxConnection )
+ ,m_xMetaData( _rxConnection->getMetaData() )
+ ,m_bInDrop( false )
+{
+}
+
+
+sdbcx::ObjectType HViews::createObject(const OUString& _rName)
+{
+ OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(m_xMetaData,
+ _rName,
+ sCatalog,
+ sSchema,
+ sTable,
+ ::dbtools::EComposeRule::InDataManipulation);
+ return new HView( m_xConnection, isCaseSensitive(), sSchema, sTable );
+}
+
+
+void HViews::impl_refresh( )
+{
+ static_cast(m_rParent).refreshTables();
+}
+
+void HViews::disposing()
+{
+m_xMetaData.clear();
+ OCollection::disposing();
+}
+
+Reference< XPropertySet > HViews::createDescriptor()
+{
+ Reference xConnection = static_cast(m_rParent).getConnection();
+ connectivity::sdbcx::OView* pNew = new connectivity::sdbcx::OView(true, xConnection->getMetaData());
+ return pNew;
+}
+
+// XAppend
+sdbcx::ObjectType HViews::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ createView(descriptor);
+ return createObject( _rForName );
+}
+
+// XDrop
+void HViews::dropObject(sal_Int32 _nPos,const OUString& /*_sElementName*/)
+{
+ if ( m_bInDrop )
+ return;
+
+ Reference< XInterface > xObject( getObject( _nPos ) );
+ bool bIsNew = connectivity::sdbcx::ODescriptor::isNew( xObject );
+ if (!bIsNew)
+ {
+ OUString aSql( "DROP VIEW" );
+
+ Reference xProp(xObject,UNO_QUERY);
+ aSql += ::dbtools::composeTableName( m_xMetaData, xProp, ::dbtools::EComposeRule::InTableDefinitions, true );
+
+ Reference xConnection = static_cast(m_rParent).getConnection();
+ Reference< XStatement > xStmt = xConnection->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+
+void HViews::dropByNameImpl(const OUString& elementName)
+{
+ m_bInDrop = true;
+ OCollection_TYPE::dropByName(elementName);
+ m_bInDrop = false;
+}
+
+void HViews::createView( const Reference< XPropertySet >& descriptor )
+{
+ Reference xConnection = static_cast(m_rParent).getConnection();
+
+ OUString sCommand;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND)) >>= sCommand;
+
+ OUString aSql = "CREATE VIEW " +
+ ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::EComposeRule::InTableDefinitions, true ) +
+ " AS " + sCommand;
+
+ Reference< XStatement > xStmt = xConnection->createStatement( );
+ if ( xStmt.is() )
+ {
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+
+ // insert the new view also in the tables collection
+ OTables* pTables = static_cast(static_cast(m_rParent).getPrivateTables());
+ if ( pTables )
+ {
+ OUString sName = ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::EComposeRule::InDataManipulation, false );
+ pTables->appendNew(sName);
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/Hservices.cxx b/connectivity/source/drivers/hsqldb/Hservices.cxx
new file mode 100644
index 000000000000..6d1294b9b072
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/Hservices.cxx
@@ -0,0 +1,105 @@
+/* -*- 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
+#include
+
+using namespace connectivity::hsqldb;
+using css::uno::Reference;
+using css::uno::Sequence;
+using css::lang::XSingleServiceFactory;
+using css::lang::XMultiServiceFactory;
+
+typedef Reference< XSingleServiceFactory > (*createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames,
+ rtl_ModuleCount*
+ );
+
+
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ sal_Char const* pImplementationName
+ )
+ : xServiceManager(static_cast(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ {
+ try
+ {
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services,nullptr);
+ }
+ catch(...)
+ {
+ }
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+
+extern "C" SAL_DLLPUBLIC_EXPORT void* hsqldb_component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ void* pRet = nullptr;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CREATE_PROVIDER(
+ ODriverDelegator::getImplementationName_Static(),
+ ODriverDelegator::getSupportedServiceNames_Static(),
+ ODriverDelegator_CreateInstance, ::cppu::createSingleFactory)
+ ;
+
+ if(aReq.xRet.is())
+ aReq.xRet->acquire();
+
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx b/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx
new file mode 100644
index 000000000000..76e506595817
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx
@@ -0,0 +1,170 @@
+/* -*- 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 .
+ */
+
+
+#if defined(HAVE_CONFIG_H) && HAVE_CONFIG_H
+#include
+#endif
+#include
+#include
+#include
+#include
+#include
+
+
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::embed;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::lang;
+using namespace ::connectivity::hsqldb;
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess
+ * Method: isStreamElement
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)Z
+ */
+extern "C" SAL_JNI_EXPORT jboolean JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_isStreamElement
+ (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name)
+{
+ TStorages::mapped_type aStoragePair = StorageContainer::getRegisteredStorage(StorageContainer::jstring2ustring(env,key));
+ auto storage = aStoragePair.mapStorage();
+ if ( storage.is() )
+ {
+ try
+ {
+ OUString sName = StorageContainer::jstring2ustring(env,name);
+ try
+ {
+ OUString sOldName = StorageContainer::removeOldURLPrefix(sName);
+ if ( storage->isStreamElement(sOldName) )
+ {
+ try
+ {
+ storage->renameElement(sOldName,StorageContainer::removeURLPrefix(sName,aStoragePair.url));
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+ }
+ catch(const NoSuchElementException&)
+ {
+ }
+ catch(const IllegalArgumentException&)
+ {
+ }
+ return storage->isStreamElement(StorageContainer::removeURLPrefix(sName,aStoragePair.url));
+ }
+ catch(const NoSuchElementException&)
+ {
+ }
+ catch(const Exception& e)
+ {
+ OSL_FAIL("Exception caught! : Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_isStreamElement");
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+ SAL_WARN("connectivity.hsqldb", "forwarding Exception: " << e);
+ }
+ }
+ return JNI_FALSE;
+}
+
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess
+ * Method: removeElement
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_removeElement
+ (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name)
+{
+#ifdef HSQLDB_DBG
+ {
+ OUString sKey = StorageContainer::jstring2ustring(env,key);
+ OUString sName = StorageContainer::jstring2ustring(env,name);
+ }
+#endif
+ TStorages::mapped_type aStoragePair = StorageContainer::getRegisteredStorage(StorageContainer::jstring2ustring(env,key));
+ auto storage = aStoragePair.mapStorage();
+ if ( storage.is() )
+ {
+ try
+ {
+ storage->removeElement(StorageContainer::removeURLPrefix(StorageContainer::jstring2ustring(env,name),aStoragePair.url));
+ }
+ catch(const NoSuchElementException&)
+ {
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
+ }
+ catch(const Exception& e)
+ {
+ SAL_WARN("connectivity.hsqldb", "Exception caught! : Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_removeElement " << e);
+ StorageContainer::throwJavaException(e,env);
+ }
+ }
+}
+
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess
+ * Method: renameElement
+ * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
+ */
+extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_renameElement
+ (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring oldname, jstring newname)
+{
+#ifdef HSQLDB_DBG
+ {
+ OUString sKey = StorageContainer::jstring2ustring(env,key);
+ OUString sNewName = StorageContainer::jstring2ustring(env,newname);
+ OUString sOldName = StorageContainer::jstring2ustring(env,oldname);
+ }
+#endif
+ TStorages::mapped_type aStoragePair = StorageContainer::getRegisteredStorage(StorageContainer::jstring2ustring(env,key));
+ auto storage = aStoragePair.mapStorage();
+ if ( storage.is() )
+ {
+ try
+ {
+ storage->renameElement(
+ StorageContainer::removeURLPrefix(StorageContainer::jstring2ustring(env,oldname),aStoragePair.url),
+ StorageContainer::removeURLPrefix(StorageContainer::jstring2ustring(env,newname),aStoragePair.url)
+ );
+#ifdef HSQLDB_DBG
+ {
+ OUString sNewName = StorageContainer::removeURLPrefix(StorageContainer::jstring2ustring(env,newname),aStoragePair.first.second);
+ OSL_ENSURE(aStoragePair.first.first->isStreamElement(sNewName),"Stream could not be renamed");
+ }
+#endif
+ }
+ catch(const NoSuchElementException&)
+ {
+ }
+ catch(const Exception& e)
+ {
+ OSL_FAIL("Exception caught! : Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_renameElement");
+ StorageContainer::throwJavaException(e,env);
+ }
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx b/connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx
new file mode 100644
index 000000000000..2c738f15f37f
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx
@@ -0,0 +1,297 @@
+/* -*- 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 .
+ */
+
+
+#if defined(HAVE_CONFIG_H) && HAVE_CONFIG_H
+#include
+#endif
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include "accesslog.hxx"
+
+#include
+
+
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::embed;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::lang;
+using namespace ::connectivity::hsqldb;
+
+/*****************************************************************************/
+/* exception macros */
+
+#define ThrowException(env, type, msg) { \
+ env->ThrowNew(env->FindClass(type), msg); }
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: openStream
+ * Signature: (Ljava/lang/String;Ljava/lang/String;I)V
+ */
+extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_openStream
+ (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name, jint mode)
+{
+#ifdef HSQLDB_DBG
+ {
+ OperationLogFile( env, name, "input" ).logOperation( "openStream" );
+ LogFile( env, name, "input" ).create();
+ }
+#endif
+ StorageContainer::registerStream(env,name,key,mode);
+}
+
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: read
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)I
+ */
+extern "C" SAL_JNI_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2
+ (JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile( env, name, "input" ).logOperation( "read()" );
+
+ DataLogFile aDataLog( env, name, "input" );
+ return read_from_storage_stream( env, obj_this, name, key, &aDataLog );
+#else
+ return read_from_storage_stream( env, name, key );
+#endif
+}
+
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: read
+ * Signature: (Ljava/lang/String;Ljava/lang/String;[BII)I
+ */
+extern "C" SAL_JNI_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2_3BII
+ (JNIEnv * env, jobject obj_this, jstring key, jstring name, jbyteArray buffer, jint off, jint len)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile( env, name, "input" ).logOperation( "read( byte[], int, int )" );
+
+ DataLogFile aDataLog( env, name, "input" );
+ return read_from_storage_stream_into_buffer( env, obj_this, name, key, buffer, off, len, &aDataLog );
+#else
+ (void)obj_this;
+ return read_from_storage_stream_into_buffer(env, name,key,buffer,off,len);
+#endif
+}
+
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: close
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_close
+ (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile aOpLog( env, name, "input" );
+ aOpLog.logOperation( "close" );
+ aOpLog.close();
+
+ LogFile aDataLog( env, name, "input" );
+ aDataLog.close();
+#endif
+ StorageContainer::revokeStream(env,name,key);
+}
+
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: skip
+ * Signature: (Ljava/lang/String;Ljava/lang/String;J)J
+ */
+extern "C" SAL_JNI_EXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_skip
+ (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name, jlong n)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile( env, name, "input" ).logOperation( "skip()" );
+#endif
+
+ if ( n < 0 )
+ ThrowException( env,
+ "java/io/IOException",
+ "n < 0");
+
+ std::shared_ptr pHelper = StorageContainer::getRegisteredStream(env,name,key);
+ OSL_ENSURE(pHelper.get(),"No stream helper!");
+ if ( pHelper.get() )
+ {
+ Reference xIn = pHelper->getInputStream();
+ if ( xIn.is() )
+ {
+ try
+ {
+ sal_Int64 tmpLongVal = n;
+ sal_Int32 tmpIntVal;
+
+ try
+ {
+ do {
+ if (tmpLongVal >= std::numeric_limits::max() )
+ tmpIntVal = std::numeric_limits::max();
+ else // Casting is safe here.
+ tmpIntVal = static_cast(tmpLongVal);
+
+ tmpLongVal -= tmpIntVal;
+
+ xIn->skipBytes(tmpIntVal);
+
+ } while (tmpLongVal > 0);
+ }
+ catch(const Exception&)
+ {
+ }
+
+ return n - tmpLongVal;
+ }
+ catch(const Exception& e)
+ {
+ OSL_FAIL("Exception caught! : skip();");
+ StorageContainer::throwJavaException(e,env);
+ }
+ }
+ }
+ else
+ {
+ ThrowException( env,
+ "java/io/IOException",
+ "Stream is not valid");
+ }
+ return 0;
+}
+
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: available
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)I
+ */
+extern "C" SAL_JNI_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_available
+ (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile aOpLog( env, name, "input" );
+ aOpLog.logOperation( "available" );
+#endif
+
+ std::shared_ptr pHelper = StorageContainer::getRegisteredStream(env,name,key);
+ OSL_ENSURE(pHelper.get(),"No stream helper!");
+ Reference xIn = pHelper.get() ? pHelper->getInputStream() : Reference();
+ if ( xIn.is() )
+ {
+ try
+ {
+ jint nAvailable = xIn->available();
+#ifdef HSQLDB_DBG
+ aOpLog.logReturn( nAvailable );
+#endif
+ return nAvailable;
+ }
+ catch(const Exception& e)
+ {
+ OSL_FAIL("Exception caught! : available();");
+ StorageContainer::throwJavaException(e,env);
+ }
+ }
+ else
+ {
+ ThrowException( env,
+ "java/io/IOException",
+ "Stream is not valid");
+ }
+ return 0;
+}
+
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: read
+ * Signature: (Ljava/lang/String;Ljava/lang/String;[B)I
+ */
+extern "C" SAL_JNI_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2_3B
+ (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name, jbyteArray buffer)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile aOpLog( env, name, "input" );
+ aOpLog.logOperation( "read( byte[] )" );
+
+ DataLogFile aDataLog( env, name, "input" );
+#endif
+
+ std::shared_ptr pHelper = StorageContainer::getRegisteredStream(env,name,key);
+ Reference< XInputStream> xIn = pHelper.get() ? pHelper->getInputStream() : Reference< XInputStream>();
+ OSL_ENSURE(xIn.is(),"Input stream is NULL!");
+ jint nBytesRead = 0;
+ if ( xIn.is() )
+ {
+ jsize nLen = env->GetArrayLength(buffer);
+ Sequence< ::sal_Int8 > aData(nLen);
+
+ try
+ {
+ nBytesRead = xIn->readBytes(aData,nLen);
+ }
+ catch(const Exception& e)
+ {
+ OSL_FAIL("Exception caught! : skip();");
+ StorageContainer::throwJavaException(e,env);
+ }
+
+ // Casting bytesRead to an int is okay, since the user can
+ // only pass in an integer length to read, so the bytesRead
+ // must <= len.
+
+ if (nBytesRead <= 0) {
+#ifdef HSQLDB_DBG
+ aOpLog.logReturn( (jint)-1 );
+#endif
+ return -1;
+ }
+ OSL_ENSURE(nLen >= nBytesRead,"Buffer is too small!");
+ OSL_ENSURE(aData.getLength() >= nBytesRead,"Buffer is too small!");
+ env->SetByteArrayRegion(buffer, 0, nBytesRead, reinterpret_cast(&aData[0]));
+#ifdef HSQLDB_DBG
+ aDataLog.write( &aData[0], nBytesRead );
+#endif
+ }
+#ifdef HSQLDB_DBG
+ aOpLog.logReturn( nBytesRead );
+#endif
+ return nBytesRead;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/accesslog.cxx b/connectivity/source/drivers/hsqldb/accesslog.cxx
new file mode 100644
index 000000000000..880600a71d5a
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/accesslog.cxx
@@ -0,0 +1,78 @@
+/* -*- 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
+
+#ifdef HSQLDB_DBG
+
+#include