tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / connectivity / source / drivers / hsqldb / StorageNativeOutputStream.cxx
blobbccbec20fcd21ee8db2c7d337a107b52c03c0e2c
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::uno;
34 using namespace ::com::sun::star::io;
35 using namespace ::connectivity::hsqldb;
39 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
40 * Method: openStream
41 * Signature: (Ljava/lang/String;Ljava/lang/String;I)V
43 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_openStream
44 (JNIEnv * env, jobject /*obj_this*/, jstring name, jstring key, jint mode)
46 #ifdef HSQLDB_DBG
48 OperationLogFile( env, name, "output" ).logOperation( "openStream" );
49 LogFile( env, name, "output" ).create();
51 #endif
52 StorageContainer::registerStream(env,name,key,mode);
55 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
56 * Method: write
57 * Signature: (Ljava/lang/String;Ljava/lang/String;[BII)V
59 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2_3BII
60 (JNIEnv * env, jobject obj_this, jstring key, jstring name, jbyteArray buffer, jint off, jint len)
62 #ifdef HSQLDB_DBG
63 OperationLogFile( env, name, "output" ).logOperation( "write( byte[], int, int )" );
65 DataLogFile aDataLog( env, name, "output" );
66 write_to_storage_stream_from_buffer( env, obj_this, name, key, buffer, off, len, &aDataLog );
67 #else
68 (void)obj_this;
69 write_to_storage_stream_from_buffer( env, name, key, buffer, off, len );
70 #endif
74 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
75 * Method: write
76 * Signature: (Ljava/lang/String;Ljava/lang/String;[B)V
78 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2_3B
79 (JNIEnv * env, jobject obj_this, jstring key, jstring name, jbyteArray buffer)
81 #ifdef HSQLDB_DBG
82 OperationLogFile( env, name, "output" ).logOperation( "write( byte[] )" );
84 DataLogFile aDataLog( env, name, "output" );
85 write_to_storage_stream_from_buffer( env, obj_this, name, key, buffer, 0, env->GetArrayLength( buffer ), &aDataLog );
86 #else
87 (void)obj_this;
88 write_to_storage_stream_from_buffer( env, name, key, buffer, 0, env->GetArrayLength( buffer ) );
89 #endif
93 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
94 * Method: close
95 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
97 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_close
98 (JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
100 #ifdef HSQLDB_DBG
101 OperationLogFile aOpLog( env, name, "output" );
102 aOpLog.logOperation( "close" );
104 LogFile aDataLog( env, name, "output" );
105 #endif
107 std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key);
108 Reference< XOutputStream> xFlush = pHelper ? pHelper->getOutputStream() : Reference< XOutputStream>();
109 if ( xFlush.is() )
112 xFlush->flush();
114 catch(Exception&)
117 #ifdef HSQLDB_DBG
118 aDataLog.close();
119 aOpLog.close();
120 #endif
121 StorageContainer::revokeStream(env,name,key);
125 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
126 * Method: write
127 * Signature: (Ljava/lang/String;Ljava/lang/String;I)V
129 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2I
130 (JNIEnv * env, jobject obj_this, jstring key, jstring name,jint b)
132 #ifdef HSQLDB_DBG
133 OperationLogFile( env, name, "output" ).logOperation( "write( int )" );
135 DataLogFile aDataLog( env, name, "output" );
136 write_to_storage_stream( env, name, key, b, &aDataLog );
137 #else
138 (void)obj_this;
139 write_to_storage_stream( env, name, key, b );
140 #endif
144 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
145 * Method: flush
146 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
148 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_flush
149 (JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
151 #ifdef HSQLDB_DBG
152 OperationLogFile( env, name, "output" ).logOperation( "flush" );
154 OUString sKey = StorageContainer::jstring2ustring(env,key);
155 OUString sName = StorageContainer::jstring2ustring(env,name);
156 #else
157 (void) env;
158 (void) key;
159 (void) name;
160 #endif
164 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
165 * Method: sync
166 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
168 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_sync
169 (JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
171 #ifdef HSQLDB_DBG
172 OperationLogFile( env, name, "output" ).logOperation( "sync" );
173 #endif
174 std::shared_ptr< StreamHelper > pStream = StorageContainer::getRegisteredStream( env, name, key );
175 Reference< XOutputStream > xFlush = pStream ? pStream->getOutputStream() : Reference< XOutputStream>();
176 OSL_ENSURE( xFlush.is(), "StorageNativeOutputStream::sync: could not retrieve an output stream!" );
177 if ( xFlush.is() )
181 xFlush->flush();
183 catch(Exception&)
185 OSL_FAIL( "StorageNativeOutputStream::sync: could not flush output stream!" );
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */