build fix
[LibreOffice.git] / connectivity / source / drivers / hsqldb / StorageNativeOutputStream.cxx
blob67e066adee05da8e4522066aeb5132c7e5f1e120
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 <uno/mapping.hxx>
25 #include <uno/environment.hxx>
26 #include <cppuhelper/bootstrap.hxx>
27 #include <cppuhelper/component_context.hxx>
28 #include "accesslog.hxx"
29 #include <com/sun/star/embed/XTransactedObject.hpp>
30 #include <comphelper/processfactory.hxx>
31 #include <com/sun/star/io/XStream.hpp>
32 #include <com/sun/star/container/XNameAccess.hpp>
33 #include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
34 #include <com/sun/star/embed/XStorage.hpp>
35 #include <com/sun/star/embed/ElementModes.hpp>
36 #include <comphelper/types.hxx>
37 #include "hsqldb/HStorageAccess.hxx"
38 #include "hsqldb/HStorageMap.hxx"
40 #include <jvmaccess/virtualmachine.hxx>
41 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
43 using namespace ::com::sun::star::container;
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::document;
46 using namespace ::com::sun::star::embed;
47 using namespace ::com::sun::star::io;
48 using namespace ::com::sun::star::lang;
49 using namespace ::connectivity::hsqldb;
53 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
54 * Method: openStream
55 * Signature: (Ljava/lang/String;Ljava/lang/String;I)V
57 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_openStream
58 (JNIEnv * env, jobject /*obj_this*/, jstring name, jstring key, jint mode)
60 #ifdef HSQLDB_DBG
62 OperationLogFile( env, name, "output" ).logOperation( "openStream" );
63 LogFile( env, name, "output" ).create();
65 #endif
66 StorageContainer::registerStream(env,name,key,mode);
69 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
70 * Method: write
71 * Signature: (Ljava/lang/String;Ljava/lang/String;[BII)V
73 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2_3BII
74 (JNIEnv * env, jobject obj_this, jstring key, jstring name, jbyteArray buffer, jint off, jint len)
76 #ifdef HSQLDB_DBG
77 OperationLogFile( env, name, "output" ).logOperation( "write( byte[], int, int )" );
79 DataLogFile aDataLog( env, name, "output" );
80 write_to_storage_stream_from_buffer( env, obj_this, name, key, buffer, off, len, &aDataLog );
81 #else
82 write_to_storage_stream_from_buffer( env, obj_this, name, key, buffer, off, len );
83 #endif
87 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
88 * Method: write
89 * Signature: (Ljava/lang/String;Ljava/lang/String;[B)V
91 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2_3B
92 (JNIEnv * env, jobject obj_this, jstring key, jstring name, jbyteArray buffer)
94 #ifdef HSQLDB_DBG
95 OperationLogFile( env, name, "output" ).logOperation( "write( byte[] )" );
97 DataLogFile aDataLog( env, name, "output" );
98 write_to_storage_stream_from_buffer( env, obj_this, name, key, buffer, 0, env->GetArrayLength( buffer ), &aDataLog );
99 #else
100 write_to_storage_stream_from_buffer( env, obj_this, name, key, buffer, 0, env->GetArrayLength( buffer ) );
101 #endif
105 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
106 * Method: close
107 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
109 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_close
110 (JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
112 #ifdef HSQLDB_DBG
113 OperationLogFile aOpLog( env, name, "output" );
114 aOpLog.logOperation( "close" );
116 LogFile aDataLog( env, name, "output" );
117 #endif
119 std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key);
120 Reference< XOutputStream> xFlush = pHelper.get() ? pHelper->getOutputStream() : Reference< XOutputStream>();
121 if ( xFlush.is() )
124 xFlush->flush();
126 catch(Exception&)
129 #ifdef HSQLDB_DBG
130 aDataLog.close();
131 aOpLog.close();
132 #endif
133 StorageContainer::revokeStream(env,name,key);
137 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
138 * Method: write
139 * Signature: (Ljava/lang/String;Ljava/lang/String;I)V
141 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2I
142 (JNIEnv * env, jobject obj_this, jstring key, jstring name,jint b)
144 #ifdef HSQLDB_DBG
145 OperationLogFile( env, name, "output" ).logOperation( "write( int )" );
147 DataLogFile aDataLog( env, name, "output" );
148 write_to_storage_stream( env, obj_this, name, key, b, &aDataLog );
149 #else
150 write_to_storage_stream( env, obj_this, name, key, b );
151 #endif
155 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
156 * Method: flush
157 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
159 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_flush
160 (JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
162 #ifdef HSQLDB_DBG
163 OperationLogFile( env, name, "output" ).logOperation( "flush" );
165 OUString sKey = StorageContainer::jstring2ustring(env,key);
166 OUString sName = StorageContainer::jstring2ustring(env,name);
167 #else
168 (void) env;
169 (void) key;
170 (void) name;
171 #endif
175 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
176 * Method: sync
177 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
179 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_sync
180 (JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
182 #ifdef HSQLDB_DBG
183 OperationLogFile( env, name, "output" ).logOperation( "sync" );
184 #endif
185 std::shared_ptr< StreamHelper > pStream = StorageContainer::getRegisteredStream( env, name, key );
186 Reference< XOutputStream > xFlush = pStream.get() ? pStream->getOutputStream() : Reference< XOutputStream>();
187 OSL_ENSURE( xFlush.is(), "StorageNativeOutputStream::sync: could not retrieve an output stream!" );
188 if ( xFlush.is() )
192 xFlush->flush();
194 catch(Exception&)
196 OSL_FAIL( "StorageNativeOutputStream::sync: could not flush output stream!" );
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */