2013-07-21 17:45:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
2014-04-18 18:41:08 +02:00
|
|
|
#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_FIREBIRD_BLOB_HXX
|
|
|
|
#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_FIREBIRD_BLOB_HXX
|
2013-07-21 17:45:08 +02:00
|
|
|
|
|
|
|
#include <ibase.h>
|
|
|
|
|
2015-07-13 11:21:57 +09:00
|
|
|
#include <cppuhelper/compbase.hxx>
|
2013-07-21 17:45:08 +02:00
|
|
|
|
2013-12-07 20:32:55 +00:00
|
|
|
#include <com/sun/star/io/XInputStream.hpp>
|
2013-07-21 17:45:08 +02:00
|
|
|
#include <com/sun/star/sdbc/XBlob.hpp>
|
|
|
|
|
|
|
|
namespace connectivity
|
|
|
|
{
|
|
|
|
namespace firebird
|
|
|
|
{
|
2016-05-27 12:31:29 +02:00
|
|
|
typedef ::cppu::WeakComponentImplHelper< css::sdbc::XBlob,
|
|
|
|
css::io::XInputStream >
|
2013-07-21 17:45:08 +02:00
|
|
|
Blob_BASE;
|
|
|
|
|
|
|
|
class Blob :
|
|
|
|
public Blob_BASE
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
::osl::Mutex m_aMutex;
|
|
|
|
|
|
|
|
isc_db_handle* m_pDatabaseHandle;
|
|
|
|
isc_tr_handle* m_pTransactionHandle;
|
|
|
|
// We store our own copy of the blob id as typically the statement
|
2016-01-09 22:55:28 +01:00
|
|
|
// manages its own blob id, and blobs are independent of a statement
|
2013-07-21 17:45:08 +02:00
|
|
|
// in firebird.
|
|
|
|
ISC_QUAD m_blobID;
|
|
|
|
isc_blob_handle m_blobHandle;
|
|
|
|
|
|
|
|
bool m_bBlobOpened;
|
2013-12-07 20:32:55 +00:00
|
|
|
sal_Int64 m_nBlobLength;
|
2017-12-13 13:46:39 +01:00
|
|
|
sal_uInt16 m_nMaxSegmentSize;
|
2013-12-07 20:32:55 +00:00
|
|
|
sal_Int64 m_nBlobPosition;
|
2013-07-21 17:45:08 +02:00
|
|
|
|
|
|
|
ISC_STATUS_ARRAY m_statusVector;
|
|
|
|
|
2017-01-19 17:59:45 +01:00
|
|
|
/// @throws css::sdbc::SQLException
|
2017-01-26 12:28:58 +01:00
|
|
|
void ensureBlobIsOpened();
|
2013-12-07 20:32:55 +00:00
|
|
|
/**
|
|
|
|
* Closes the blob and cleans up resources -- can be used to reset
|
|
|
|
* the blob if we e.g. want to read from the beginning again.
|
2017-01-19 17:59:45 +01:00
|
|
|
*
|
|
|
|
* @throws css::sdbc::SQLException
|
2013-12-07 20:32:55 +00:00
|
|
|
*/
|
2017-01-26 12:28:58 +01:00
|
|
|
void closeBlob();
|
2017-12-13 13:46:39 +01:00
|
|
|
sal_uInt16 getMaximumSegmentSize();
|
2013-07-21 17:45:08 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
Blob(isc_db_handle* pDatabaseHandle,
|
|
|
|
isc_tr_handle* pTransactionHandle,
|
2017-07-28 11:47:51 +02:00
|
|
|
ISC_QUAD const & aBlobID);
|
2013-07-21 17:45:08 +02:00
|
|
|
|
2017-12-13 13:46:39 +01:00
|
|
|
bool readOneSegment(css::uno::Sequence< sal_Int8 >& rDataOut);
|
|
|
|
|
2013-07-21 17:45:08 +02:00
|
|
|
// ---- XBlob ----------------------------------------------------
|
|
|
|
virtual sal_Int64 SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
length() override;
|
2016-05-27 12:31:29 +02:00
|
|
|
virtual css::uno::Sequence< sal_Int8 > SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
getBytes(sal_Int64 aPosition, sal_Int32 aLength) override;
|
2016-05-27 12:31:29 +02:00
|
|
|
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
getBinaryStream() override;
|
2013-07-21 17:45:08 +02:00
|
|
|
virtual sal_Int64 SAL_CALL
|
2016-05-27 12:31:29 +02:00
|
|
|
position(const css::uno::Sequence< sal_Int8 >& rPattern,
|
2017-01-26 12:28:58 +01:00
|
|
|
sal_Int64 aStart) override;
|
2013-07-21 17:45:08 +02:00
|
|
|
virtual sal_Int64 SAL_CALL
|
2016-05-27 12:31:29 +02:00
|
|
|
positionOfBlob(const css::uno::Reference< css::sdbc::XBlob >& rPattern,
|
2017-01-26 12:28:58 +01:00
|
|
|
sal_Int64 aStart) override;
|
2013-07-21 17:45:08 +02:00
|
|
|
|
2013-12-07 20:32:55 +00:00
|
|
|
// ---- XInputStream ----------------------------------------------
|
|
|
|
virtual sal_Int32 SAL_CALL
|
2016-05-27 12:31:29 +02:00
|
|
|
readBytes(css::uno::Sequence< sal_Int8 >& rDataOut,
|
2017-01-26 12:28:58 +01:00
|
|
|
sal_Int32 nBytes) override;
|
2013-12-07 20:32:55 +00:00
|
|
|
virtual sal_Int32 SAL_CALL
|
2016-05-27 12:31:29 +02:00
|
|
|
readSomeBytes(css::uno::Sequence< sal_Int8 >& rDataOut,
|
2017-01-26 12:28:58 +01:00
|
|
|
sal_Int32 nMaximumBytes) override;
|
2013-12-07 20:32:55 +00:00
|
|
|
virtual void SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
skipBytes(sal_Int32 nBytes) override;
|
2013-12-07 20:32:55 +00:00
|
|
|
virtual sal_Int32 SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
available() override;
|
2013-12-07 20:32:55 +00:00
|
|
|
virtual void SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
closeInput() override;
|
2013-12-07 20:32:55 +00:00
|
|
|
|
2013-07-21 17:45:08 +02:00
|
|
|
// ---- OComponentHelper ------------------------------------------
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void SAL_CALL disposing() override;
|
2013-07-21 17:45:08 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-04-18 18:41:08 +02:00
|
|
|
#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_FIREBIRD_BLOB_HXX
|
2016-01-09 22:55:28 +01:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|