21#if defined(HAVE_CONFIG_H) && HAVE_CONFIG_H
24#include <com/sun/star/io/XStream.hpp>
25#include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
29#include <osl/diagnose.h>
47#define ThrowException(env, type, msg) { \
48 env->ThrowNew(env->FindClass(type), msg); }
55 (JNIEnv * env, jobject ,jstring key, jstring
name, jint mode)
59 OperationLogFile(
env,
name,
"input" ).logOperation(
"openStream" );
60 LogFile(
env,
name,
"input" ).create();
63 StorageContainer::registerStream(
env,
name,key,
mode);
73 (JNIEnv * env, jobject , jstring key, jstring
name)
76 OperationLogFile(
env,
name,
"input" ).logOperation(
"read()" );
78 DataLogFile aDataLog(
env,
name,
"input" );
92 (JNIEnv * env, jobject obj_this, jstring key, jstring
name, jbyteArray buffer, jint off, jint len)
95 OperationLogFile(
env,
name,
"input" ).logOperation(
"read( byte[], int, int )" );
97 DataLogFile aDataLog(
env,
name,
"input" );
112 (JNIEnv * env, jobject ,jstring key, jstring
name)
115 OperationLogFile aOpLog(
env,
name,
"input" );
116 aOpLog.logOperation(
"close" );
119 LogFile aDataLog(
env,
name,
"input" );
122 StorageContainer::revokeStream(
env,
name,key);
132 (JNIEnv * env, jobject ,jstring key, jstring
name, jlong n)
135 OperationLogFile(
env,
name,
"input" ).logOperation(
"skip()" );
140 "java/io/IOException",
143 std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(
env,
name,key);
144 OSL_ENSURE(pHelper,
"No stream helper!");
147 Reference<XInputStream> xIn = pHelper->getInputStream();
152 sal_Int64 tmpLongVal =
n;
158 if (tmpLongVal >= std::numeric_limits<sal_Int64>::max() )
159 tmpIntVal = std::numeric_limits<sal_Int32>::max();
161 tmpIntVal =
static_cast<sal_Int32
>(tmpLongVal);
163 tmpLongVal -= tmpIntVal;
165 xIn->skipBytes(tmpIntVal);
167 }
while (tmpLongVal > 0);
173 return n - tmpLongVal;
178 StorageContainer::throwJavaException(e,
env);
185 "java/io/IOException",
186 "Stream is not valid");
198 (JNIEnv * env, jobject ,jstring key, jstring
name)
201 OperationLogFile aOpLog(
env,
name,
"input" );
202 aOpLog.logOperation(
"available" );
205 std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(
env,
name,key);
206 OSL_ENSURE(pHelper,
"No stream helper!");
207 Reference<XInputStream> xIn = pHelper ? pHelper->getInputStream() : Reference<XInputStream>();
212 jint nAvailable = xIn->available();
214 aOpLog.logReturn( nAvailable );
221 StorageContainer::throwJavaException(e,
env);
227 "java/io/IOException",
228 "Stream is not valid");
240 (JNIEnv * env, jobject ,jstring key, jstring
name, jbyteArray buffer)
243 OperationLogFile aOpLog(
env,
name,
"input" );
244 aOpLog.logOperation(
"read( byte[] )" );
246 DataLogFile aDataLog(
env,
name,
"input" );
249 std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(
env,
name,key);
250 Reference< XInputStream> xIn = pHelper ? pHelper->getInputStream() : Reference< XInputStream>();
251 OSL_ENSURE(xIn.is(),
"Input stream is NULL!");
255 jsize nLen =
env->GetArrayLength(buffer);
256 Sequence< ::sal_Int8 >
aData(nLen);
260 nBytesRead = xIn->readBytes(
aData,nLen);
265 StorageContainer::throwJavaException(e,
env);
272 if (nBytesRead <= 0) {
274 aOpLog.logReturn( (jint)-1 );
278 OSL_ENSURE(nLen >= nBytesRead,
"Buffer is too small!");
279 OSL_ENSURE(
aData.getLength() >= nBytesRead,
"Buffer is too small!");
280 env->SetByteArrayRegion(buffer, 0, nBytesRead,
reinterpret_cast<const jbyte*
>(&
aData[0]));
282 aDataLog.write( &
aData[0], nBytesRead );
286 aOpLog.logReturn( nBytesRead );
jint read_from_storage_stream_into_buffer(JNIEnv *env, jstring name, jstring key, jbyteArray buffer, jint off, jint len)
jint read_from_storage_stream(JNIEnv *env, jstring name, jstring key)
#define TOOLS_WARN_EXCEPTION(area, stream)
const css::uno::Reference< css::xml::crypto::XSecurityEnvironment > & env
constexpr OUStringLiteral aData