1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
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
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
)
52 OperationLogFile( env
, name
, "output" ).logOperation( "openStream" );
53 LogFile( env
, name
, "output" ).create();
56 StorageContainer::registerStream(env
,name
,key
,mode
);
59 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
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
)
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
);
73 write_to_storage_stream_from_buffer( env
, name
, key
, buffer
, off
, len
);
78 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
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
)
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
);
92 write_to_storage_stream_from_buffer( env
, name
, key
, buffer
, 0, env
->GetArrayLength( buffer
) );
97 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
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
)
105 OperationLogFile
aOpLog( env
, name
, "output" );
106 aOpLog
.logOperation( "close" );
108 LogFile
aDataLog( env
, name
, "output" );
111 std::shared_ptr
<StreamHelper
> pHelper
= StorageContainer::getRegisteredStream(env
,name
,key
);
112 Reference
< XOutputStream
> xFlush
= pHelper
? pHelper
->getOutputStream() : Reference
< XOutputStream
>();
125 StorageContainer::revokeStream(env
,name
,key
);
129 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
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
)
137 OperationLogFile( env
, name
, "output" ).logOperation( "write( int )" );
139 DataLogFile
aDataLog( env
, name
, "output" );
140 write_to_storage_stream( env
, name
, key
, b
, &aDataLog
);
143 write_to_storage_stream( env
, name
, key
, b
);
148 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
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
)
156 OperationLogFile( env
, name
, "output" ).logOperation( "flush" );
158 OUString sKey
= StorageContainer::jstring2ustring(env
,key
);
159 OUString sName
= StorageContainer::jstring2ustring(env
,name
);
168 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
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
)
176 OperationLogFile( env
, name
, "output" ).logOperation( "sync" );
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!" );
189 OSL_FAIL( "StorageNativeOutputStream::sync: could not flush output stream!" );
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */