#i105086# fix blob handling, map to bytes when possible
This commit is contained in:
@@ -1,4 +1,33 @@
|
|||||||
/*
|
/*************************************************************************
|
||||||
|
*
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* Copyright 2008 by Sun Microsystems, Inc.
|
||||||
|
*
|
||||||
|
* OpenOffice.org - a multi-platform office productivity suite
|
||||||
|
*
|
||||||
|
* $RCSfile: StorageFileAccess.java,v $
|
||||||
|
* $Revision: 1.11 $
|
||||||
|
*
|
||||||
|
* This file is part of OpenOffice.org.
|
||||||
|
*
|
||||||
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License version 3
|
||||||
|
* only, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License version 3 for more details
|
||||||
|
* (a copy is included in the LICENSE file that accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* version 3 along with OpenOffice.org. If not, see
|
||||||
|
* <http://www.openoffice.org/license.html>
|
||||||
|
* for a copy of the LGPLv3 License.
|
||||||
|
*
|
||||||
|
************************************************************************/
|
||||||
|
/*
|
||||||
* NativeInputStreamHelper.java
|
* NativeInputStreamHelper.java
|
||||||
*
|
*
|
||||||
* Created on 9. September 2004, 11:51
|
* Created on 9. September 2004, 11:51
|
||||||
|
@@ -1,3 +1,32 @@
|
|||||||
|
/*************************************************************************
|
||||||
|
*
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* Copyright 2008 by Sun Microsystems, Inc.
|
||||||
|
*
|
||||||
|
* OpenOffice.org - a multi-platform office productivity suite
|
||||||
|
*
|
||||||
|
* $RCSfile: StorageFileAccess.java,v $
|
||||||
|
* $Revision: 1.11 $
|
||||||
|
*
|
||||||
|
* This file is part of OpenOffice.org.
|
||||||
|
*
|
||||||
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License version 3
|
||||||
|
* only, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License version 3 for more details
|
||||||
|
* (a copy is included in the LICENSE file that accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* version 3 along with OpenOffice.org. If not, see
|
||||||
|
* <http://www.openoffice.org/license.html>
|
||||||
|
* for a copy of the LGPLv3 License.
|
||||||
|
*
|
||||||
|
************************************************************************/
|
||||||
/*
|
/*
|
||||||
* StorageNativeInputStream.java
|
* StorageNativeInputStream.java
|
||||||
*
|
*
|
||||||
|
54
connectivity/inc/connectivity/BlobHelper.hxx
Normal file
54
connectivity/inc/connectivity/BlobHelper.hxx
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*************************************************************************
|
||||||
|
*
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* Copyright 2008 by Sun Microsystems, Inc.
|
||||||
|
*
|
||||||
|
* OpenOffice.org - a multi-platform office productivity suite
|
||||||
|
*
|
||||||
|
* $RCSfile: FValue.cxx,v $
|
||||||
|
* $Revision: 1.34 $
|
||||||
|
*
|
||||||
|
* This file is part of OpenOffice.org.
|
||||||
|
*
|
||||||
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License version 3
|
||||||
|
* only, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License version 3 for more details
|
||||||
|
* (a copy is included in the LICENSE file that accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* version 3 along with OpenOffice.org. If not, see
|
||||||
|
* <http://www.openoffice.org/license.html>
|
||||||
|
* for a copy of the LGPLv3 License.
|
||||||
|
*
|
||||||
|
************************************************************************/
|
||||||
|
#ifndef _CONNECTIVITY_BLOBHELPER_HXX_
|
||||||
|
#define _CONNECTIVITY_BLOBHELPER_HXX_
|
||||||
|
|
||||||
|
#include "connectivity/dbtoolsdllapi.hxx"
|
||||||
|
#include <com/sun/star/sdbc/XBlob.hpp>
|
||||||
|
#include <cppuhelper/implbase1.hxx>
|
||||||
|
|
||||||
|
namespace connectivity
|
||||||
|
{
|
||||||
|
class OOO_DLLPUBLIC_DBTOOLS BlobHelper : public ::cppu::WeakImplHelper1< com::sun::star::sdbc::XBlob >
|
||||||
|
{
|
||||||
|
::com::sun::star::uno::Sequence< sal_Int8 > m_aValue;
|
||||||
|
public:
|
||||||
|
BlobHelper(const ::com::sun::star::uno::Sequence< sal_Int8 >& _val);
|
||||||
|
private:
|
||||||
|
virtual ::sal_Int64 SAL_CALL length( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
||||||
|
virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getBytes( ::sal_Int64 pos, ::sal_Int32 length ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
||||||
|
virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
||||||
|
virtual ::sal_Int64 SAL_CALL position( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& pattern, ::sal_Int64 start ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
||||||
|
virtual ::sal_Int64 SAL_CALL positionOfBlob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& pattern, ::sal_Int64 start ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //_CONNECTIVITY_BLOBHELPER_HXX_
|
||||||
|
|
72
connectivity/source/commontools/BlobHelper.cxx
Normal file
72
connectivity/source/commontools/BlobHelper.cxx
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/*************************************************************************
|
||||||
|
*
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* Copyright 2008 by Sun Microsystems, Inc.
|
||||||
|
*
|
||||||
|
* OpenOffice.org - a multi-platform office productivity suite
|
||||||
|
*
|
||||||
|
* $RCSfile: FValue.cxx,v $
|
||||||
|
* $Revision: 1.34 $
|
||||||
|
*
|
||||||
|
* This file is part of OpenOffice.org.
|
||||||
|
*
|
||||||
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License version 3
|
||||||
|
* only, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License version 3 for more details
|
||||||
|
* (a copy is included in the LICENSE file that accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* version 3 along with OpenOffice.org. If not, see
|
||||||
|
* <http://www.openoffice.org/license.html>
|
||||||
|
* for a copy of the LGPLv3 License.
|
||||||
|
*
|
||||||
|
************************************************************************/
|
||||||
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
||||||
|
#include "precompiled_connectivity.hxx"
|
||||||
|
#include "connectivity/BlobHelper.hxx"
|
||||||
|
#include <comphelper/seqstream.hxx>
|
||||||
|
#include "connectivity/dbexception.hxx"
|
||||||
|
|
||||||
|
using namespace connectivity;
|
||||||
|
using namespace dbtools;
|
||||||
|
using namespace ::com::sun::star::sdbc;
|
||||||
|
using namespace ::com::sun::star::uno;
|
||||||
|
|
||||||
|
BlobHelper::BlobHelper(const ::com::sun::star::uno::Sequence< sal_Int8 >& _val) : m_aValue(_val)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
::sal_Int64 SAL_CALL BlobHelper::length( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
||||||
|
{
|
||||||
|
return m_aValue.getLength();
|
||||||
|
}
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL BlobHelper::getBytes( ::sal_Int64 pos, ::sal_Int32 length ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
||||||
|
{
|
||||||
|
if ( sal_Int32(pos + length) > m_aValue.getLength() )
|
||||||
|
throw ::com::sun::star::sdbc::SQLException();
|
||||||
|
return ::com::sun::star::uno::Sequence< ::sal_Int8 >(m_aValue.getConstArray() + sal_Int32(pos),length);
|
||||||
|
}
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL BlobHelper::getBinaryStream( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
||||||
|
{
|
||||||
|
return new ::comphelper::SequenceInputStream(m_aValue);
|
||||||
|
}
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
::sal_Int64 SAL_CALL BlobHelper::position( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& /*pattern*/, ::sal_Int64 /*start*/ ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
||||||
|
{
|
||||||
|
::dbtools::throwFeatureNotImplementedException( "XBlob::position", *this );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
::sal_Int64 SAL_CALL BlobHelper::positionOfBlob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& /*pattern*/, ::sal_Int64 /*start*/ ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
||||||
|
{
|
||||||
|
::dbtools::throwFeatureNotImplementedException( "XBlob::positionOfBlob", *this );
|
||||||
|
return 0;
|
||||||
|
}
|
@@ -1643,12 +1643,39 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const
|
|||||||
case DataType::BLOB:
|
case DataType::BLOB:
|
||||||
{
|
{
|
||||||
Reference<XInputStream> xStream;
|
Reference<XInputStream> xStream;
|
||||||
Any aValue = getAny();
|
const Any aValue = makeAny();
|
||||||
if(aValue.hasValue())
|
if(aValue.hasValue())
|
||||||
{
|
{
|
||||||
aValue >>= xStream;
|
Reference<XBlob> xBlob(aValue,UNO_QUERY);
|
||||||
|
if ( xBlob.is() )
|
||||||
|
xStream = xBlob->getBinaryStream();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Reference<XClob> xClob(aValue,UNO_QUERY);
|
||||||
|
if ( xClob.is() )
|
||||||
|
xStream = xClob->getCharacterStream();
|
||||||
|
}
|
||||||
if(xStream.is())
|
if(xStream.is())
|
||||||
xStream->readBytes(aSeq,xStream->available());
|
{
|
||||||
|
const sal_uInt32 nBytesToRead = 65535;
|
||||||
|
sal_uInt32 nRead;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
::com::sun::star::uno::Sequence< sal_Int8 > aReadSeq;
|
||||||
|
|
||||||
|
nRead = xStream->readSomeBytes( aReadSeq, nBytesToRead );
|
||||||
|
|
||||||
|
if( nRead )
|
||||||
|
{
|
||||||
|
const sal_uInt32 nOldLength = aSeq.getLength();
|
||||||
|
aSeq.realloc( nOldLength + nRead );
|
||||||
|
rtl_copyMemory( aSeq.getArray() + nOldLength, aReadSeq.getConstArray(), aReadSeq.getLength() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while( nBytesToRead == nRead );
|
||||||
|
xStream->closeInput();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2117,6 +2144,10 @@ void ORowSetValue::fill(const Any& _rValue)
|
|||||||
(*this) = _rValue;
|
(*this) = _rValue;
|
||||||
setTypeKind(DataType::BLOB);
|
setTypeKind(DataType::BLOB);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
(*this) = _rValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@@ -89,6 +89,7 @@ EXCEPTIONSFILES=\
|
|||||||
$(SLO)$/ParamterSubstitution.obj \
|
$(SLO)$/ParamterSubstitution.obj \
|
||||||
$(SLO)$/DriversConfig.obj \
|
$(SLO)$/DriversConfig.obj \
|
||||||
$(SLO)$/formattedcolumnvalue.obj \
|
$(SLO)$/formattedcolumnvalue.obj \
|
||||||
|
$(SLO)$/BlobHelper.obj \
|
||||||
$(SLO)$/warningscontainer.obj
|
$(SLO)$/warningscontainer.obj
|
||||||
|
|
||||||
SLOFILES=\
|
SLOFILES=\
|
||||||
|
@@ -784,14 +784,24 @@ void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::s
|
|||||||
}
|
}
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException)
|
void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
|
||||||
{
|
{
|
||||||
::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateBinaryStream", *this );
|
if(!x.is())
|
||||||
|
::dbtools::throwFunctionSequenceException(*this);
|
||||||
|
|
||||||
|
Sequence<sal_Int8> aSeq;
|
||||||
|
x->readBytes(aSeq,length);
|
||||||
|
updateBytes(columnIndex,aSeq);
|
||||||
}
|
}
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException)
|
void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
|
||||||
{
|
{
|
||||||
::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateCharacterStream", *this );
|
if(!x.is())
|
||||||
|
::dbtools::throwFunctionSequenceException(*this);
|
||||||
|
|
||||||
|
Sequence<sal_Int8> aSeq;
|
||||||
|
x->readBytes(aSeq,length);
|
||||||
|
updateBytes(columnIndex,aSeq);
|
||||||
}
|
}
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException)
|
void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException)
|
||||||
|
@@ -84,8 +84,9 @@ void SAL_CALL java_io_InputStream::closeInput( ) throw(::com::sun::star::io::No
|
|||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
sal_Int32 SAL_CALL java_io_InputStream::readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
|
sal_Int32 SAL_CALL java_io_InputStream::readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
|
||||||
{
|
{
|
||||||
if ( aData.getLength() < nBytesToRead )
|
if (nBytesToRead < 0)
|
||||||
throw ::com::sun::star::io::BufferSizeExceededException();
|
throw ::com::sun::star::io::BufferSizeExceededException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), *this );
|
||||||
|
|
||||||
jint out(0);
|
jint out(0);
|
||||||
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
||||||
|
|
||||||
@@ -102,7 +103,8 @@ sal_Int32 SAL_CALL java_io_InputStream::readBytes( ::com::sun::star::uno::Sequen
|
|||||||
if(out > 0)
|
if(out > 0)
|
||||||
{
|
{
|
||||||
jboolean p = sal_False;
|
jboolean p = sal_False;
|
||||||
memcpy(aData.getArray(),t.pEnv->GetByteArrayElements(pByteArray,&p),out);
|
aData.realloc ( out );
|
||||||
|
rtl_copyMemory(aData.getArray(),t.pEnv->GetByteArrayElements(pByteArray,&p),out);
|
||||||
}
|
}
|
||||||
t.pEnv->DeleteLocalRef((jbyteArray)pByteArray);
|
t.pEnv->DeleteLocalRef((jbyteArray)pByteArray);
|
||||||
} //t.pEnv
|
} //t.pEnv
|
||||||
|
@@ -786,16 +786,68 @@ void SAL_CALL java_sql_ResultSet::updateTimestamp( sal_Int32 columnIndex, const
|
|||||||
}
|
}
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
void SAL_CALL java_sql_ResultSet::updateBinaryStream( sal_Int32 /*columnIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
void SAL_CALL java_sql_ResultSet::updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
||||||
{
|
{
|
||||||
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateBinaryStream" );
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateBinaryStream" );
|
||||||
::dbtools::throwFeatureNotImplementedException( "XParameters::updateBinaryStream", *this );
|
try
|
||||||
|
{
|
||||||
|
SDBThreadAttach t;
|
||||||
|
{
|
||||||
|
|
||||||
|
// temporaere Variable initialisieren
|
||||||
|
// Java-Call absetzen
|
||||||
|
static jmethodID mID(NULL);
|
||||||
|
if ( !mID )
|
||||||
|
{
|
||||||
|
static const char * cSignature = "(ILjava/io/InputStream;I)V";
|
||||||
|
static const char * cMethodName = "updateBinaryStream";
|
||||||
|
obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Parameter konvertieren
|
||||||
|
jobject obj = createByteInputStream(x,length);
|
||||||
|
t.pEnv->CallVoidMethod( object, mID, columnIndex,obj,length);
|
||||||
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception)
|
||||||
|
{
|
||||||
|
::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateBinaryStream", *this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
void SAL_CALL java_sql_ResultSet::updateCharacterStream( sal_Int32 /*columnIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
void SAL_CALL java_sql_ResultSet::updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
||||||
{
|
{
|
||||||
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateCharacterStream" );
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateCharacterStream" );
|
||||||
::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateCharacterStream", *this );
|
try
|
||||||
|
{
|
||||||
|
SDBThreadAttach t;
|
||||||
|
{
|
||||||
|
|
||||||
|
// temporaere Variable initialisieren
|
||||||
|
// Java-Call absetzen
|
||||||
|
static jmethodID mID(NULL);
|
||||||
|
if ( !mID )
|
||||||
|
{
|
||||||
|
static const char * cSignature = "(ILjava/io/Reader;I)V";
|
||||||
|
static const char * cMethodName = "updateCharacterStream";
|
||||||
|
obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Parameter konvertieren
|
||||||
|
jobject obj = createCharArrayReader(x,length);
|
||||||
|
t.pEnv->CallVoidMethod( object, mID, columnIndex,obj,length);
|
||||||
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception)
|
||||||
|
{
|
||||||
|
::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateCharacterStream", *this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
void SAL_CALL java_sql_ResultSet::updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
void SAL_CALL java_sql_ResultSet::updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
||||||
|
@@ -218,5 +218,58 @@ sal_Bool connectivity::isExceptionOccured(JNIEnv *pEnv,sal_Bool _bClear)
|
|||||||
|
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
jobject connectivity::createByteInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length)
|
||||||
|
{
|
||||||
|
SDBThreadAttach t;
|
||||||
|
if( !t.pEnv || !x.is() )
|
||||||
|
return NULL;
|
||||||
|
// Java-Call fuer den Konstruktor absetzen
|
||||||
|
// temporaere Variable initialisieren
|
||||||
|
jclass clazz = java_lang_Object::findMyClass("java/io/ByteArrayInputStream");
|
||||||
|
static jmethodID mID(NULL);
|
||||||
|
if ( !mID )
|
||||||
|
{
|
||||||
|
static const char * cSignature = "([B)V";
|
||||||
|
mID = t.pEnv->GetMethodID( clazz, "<init>", cSignature );
|
||||||
|
OSL_ENSURE( mID, cSignature );
|
||||||
|
if ( !mID )
|
||||||
|
throw SQLException();
|
||||||
|
} // if ( !_inout_MethodID )
|
||||||
|
jbyteArray pByteArray = t.pEnv->NewByteArray(length);
|
||||||
|
Sequence< sal_Int8 > aData;
|
||||||
|
x->readBytes(aData,length);
|
||||||
|
jboolean p = sal_False;
|
||||||
|
rtl_copyMemory(t.pEnv->GetByteArrayElements(pByteArray,&p),aData.getArray(),aData.getLength());
|
||||||
|
jobject out = t.pEnv->NewObject( clazz, mID,pByteArray);
|
||||||
|
t.pEnv->DeleteLocalRef((jbyteArray)pByteArray);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
jobject connectivity::createCharArrayReader(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length)
|
||||||
|
{
|
||||||
|
SDBThreadAttach t;
|
||||||
|
if( !t.pEnv || !x.is() )
|
||||||
|
return NULL;
|
||||||
|
// Java-Call fuer den Konstruktor absetzen
|
||||||
|
// temporaere Variable initialisieren
|
||||||
|
jclass clazz = java_lang_Object::findMyClass("java/io/CharArrayReader");
|
||||||
|
static jmethodID mID(NULL);
|
||||||
|
if ( !mID )
|
||||||
|
{
|
||||||
|
static const char * cSignature = "([C)V";
|
||||||
|
mID = t.pEnv->GetMethodID( clazz, "<init>", cSignature );
|
||||||
|
OSL_ENSURE( mID, cSignature );
|
||||||
|
if ( !mID )
|
||||||
|
throw SQLException();
|
||||||
|
} // if ( !_inout_MethodID )
|
||||||
|
jcharArray pCharArray = t.pEnv->NewCharArray(length);
|
||||||
|
Sequence< sal_Int8 > aData;
|
||||||
|
x->readBytes(aData,length);
|
||||||
|
jboolean p = sal_False;
|
||||||
|
rtl_copyMemory(t.pEnv->GetCharArrayElements(pCharArray,&p),aData.getArray(),aData.getLength());
|
||||||
|
jobject out = t.pEnv->NewObject( clazz, mID,pCharArray);
|
||||||
|
t.pEnv->DeleteLocalRef((jcharArray)pCharArray);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
#include <comphelper/uno3.hxx>
|
#include <comphelper/uno3.hxx>
|
||||||
|
|
||||||
#include <com/sun/star/container/XNameAccess.hpp>
|
#include <com/sun/star/container/XNameAccess.hpp>
|
||||||
|
#include <com/sun/star/io/XInputStream.hpp>
|
||||||
#include <com/sun/star/util/Time.hpp>
|
#include <com/sun/star/util/Time.hpp>
|
||||||
#include <com/sun/star/util/Date.hpp>
|
#include <com/sun/star/util/Date.hpp>
|
||||||
#include <com/sun/star/util/DateTime.hpp>
|
#include <com/sun/star/util/DateTime.hpp>
|
||||||
@@ -85,6 +86,9 @@ namespace connectivity
|
|||||||
<TRUE/> if an exception is occured
|
<TRUE/> if an exception is occured
|
||||||
*/
|
*/
|
||||||
sal_Bool isExceptionOccured(JNIEnv *pEnv,sal_Bool _bClear);
|
sal_Bool isExceptionOccured(JNIEnv *pEnv,sal_Bool _bClear);
|
||||||
|
|
||||||
|
jobject createByteInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length);
|
||||||
|
jobject createCharArrayReader(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // _CONNECTIVITY_JAVA_TOOLS_HXX_
|
#endif // _CONNECTIVITY_JAVA_TOOLS_HXX_
|
||||||
|
Reference in New Issue
Block a user