bump product version to 7.2.5.1
[LibreOffice.git] / connectivity / source / drivers / hsqldb / StorageNativeOutputStream.cxx
blobf766696e0d9b8702c9c130f3b7b318ff4be499d5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #if defined(HAVE_CONFIG_H) && HAVE_CONFIG_H
21 #include <config.h>
22 #endif
24 #include <cppuhelper/bootstrap.hxx>
25 #include <osl/diagnose.h>
26 #include "accesslog.hxx"
27 #include <com/sun/star/embed/XTransactedObject.hpp>
28 #include <com/sun/star/io/XStream.hpp>
29 #include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
30 #include <hsqldb/HStorageAccess.hxx>
31 #include <hsqldb/HStorageMap.hxx>
33 using namespace ::com::sun::star::container;
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::document;
36 using namespace ::com::sun::star::embed;
37 using namespace ::com::sun::star::io;
38 using namespace ::com::sun::star::lang;
39 using namespace ::connectivity::hsqldb;
43 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
44 * Method: openStream
45 * Signature: (Ljava/lang/String;Ljava/lang/String;I)V
47 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_openStream
48 (JNIEnv * env, jobject /*obj_this*/, jstring name, jstring key, jint mode)
50 #ifdef HSQLDB_DBG
52 OperationLogFile( env, name, "output" ).logOperation( "openStream" );
53 LogFile( env, name, "output" ).create();
55 #endif
56 StorageContainer::registerStream(env,name,key,mode);
59 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
60 * Method: write
61 * Signature: (Ljava/lang/String;Ljava/lang/String;[BII)V
63 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2_3BII
64 (JNIEnv * env, jobject obj_this, jstring key, jstring name, jbyteArray buffer, jint off, jint len)
66 #ifdef HSQLDB_DBG
67 OperationLogFile( env, name, "output" ).logOperation( "write( byte[], int, int )" );
69 DataLogFile aDataLog( env, name, "output" );
70 write_to_storage_stream_from_buffer( env, obj_this, name, key, buffer, off, len, &aDataLog );
71 #else
72 (void)obj_this;
73 write_to_storage_stream_from_buffer( env, name, key, buffer, off, len );
74 #endif
78 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
79 * Method: write
80 * Signature: (Ljava/lang/String;Ljava/lang/String;[B)V
82 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2_3B
83 (JNIEnv * env, jobject obj_this, jstring key, jstring name, jbyteArray buffer)
85 #ifdef HSQLDB_DBG
86 OperationLogFile( env, name, "output" ).logOperation( "write( byte[] )" );
88 DataLogFile aDataLog( env, name, "output" );
89 write_to_storage_stream_from_buffer( env, obj_this, name, key, buffer, 0, env->GetArrayLength( buffer ), &aDataLog );
90 #else
91 (void)obj_this;
92 write_to_storage_stream_from_buffer( env, name, key, buffer, 0, env->GetArrayLength( buffer ) );
93 #endif
97 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
98 * Method: close
99 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
101 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_close
102 (JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
104 #ifdef HSQLDB_DBG
105 OperationLogFile aOpLog( env, name, "output" );
106 aOpLog.logOperation( "close" );
108 LogFile aDataLog( env, name, "output" );
109 #endif
111 std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key);
112 Reference< XOutputStream> xFlush = pHelper ? pHelper->getOutputStream() : Reference< XOutputStream>();
113 if ( xFlush.is() )
116 xFlush->flush();
118 catch(Exception&)
121 #ifdef HSQLDB_DBG
122 aDataLog.close();
123 aOpLog.close();
124 #endif
125 StorageContainer::revokeStream(env,name,key);
129 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
130 * Method: write
131 * Signature: (Ljava/lang/String;Ljava/lang/String;I)V
133 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2I
134 (JNIEnv * env, jobject obj_this, jstring key, jstring name,jint b)
136 #ifdef HSQLDB_DBG
137 OperationLogFile( env, name, "output" ).logOperation( "write( int )" );
139 DataLogFile aDataLog( env, name, "output" );
140 write_to_storage_stream( env, name, key, b, &aDataLog );
141 #else
142 (void)obj_this;
143 write_to_storage_stream( env, name, key, b );
144 #endif
148 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
149 * Method: flush
150 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
152 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_flush
153 (JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
155 #ifdef HSQLDB_DBG
156 OperationLogFile( env, name, "output" ).logOperation( "flush" );
158 OUString sKey = StorageContainer::jstring2ustring(env,key);
159 OUString sName = StorageContainer::jstring2ustring(env,name);
160 #else
161 (void) env;
162 (void) key;
163 (void) name;
164 #endif
168 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
169 * Method: sync
170 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
172 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_sync
173 (JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
175 #ifdef HSQLDB_DBG
176 OperationLogFile( env, name, "output" ).logOperation( "sync" );
177 #endif
178 std::shared_ptr< StreamHelper > pStream = StorageContainer::getRegisteredStream( env, name, key );
179 Reference< XOutputStream > xFlush = pStream ? pStream->getOutputStream() : Reference< XOutputStream>();
180 OSL_ENSURE( xFlush.is(), "StorageNativeOutputStream::sync: could not retrieve an output stream!" );
181 if ( xFlush.is() )
185 xFlush->flush();
187 catch(Exception&)
189 OSL_FAIL( "StorageNativeOutputStream::sync: could not flush output stream!" );
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */