1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #include "connectivity/BlobHelper.hxx"
29 #include <comphelper/seqstream.hxx>
30 #include "connectivity/dbexception.hxx"
32 using namespace connectivity
;
33 using namespace dbtools
;
34 using namespace ::com::sun::star::sdbc
;
35 using namespace ::com::sun::star::uno
;
37 BlobHelper::BlobHelper(const ::com::sun::star::uno::Sequence
< sal_Int8
>& _val
) : m_aValue(_val
)
40 // -----------------------------------------------------------------------------
41 ::sal_Int64 SAL_CALL
BlobHelper::length( ) throw (::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
43 return m_aValue
.getLength();
45 // -----------------------------------------------------------------------------
46 ::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
)
48 if ( sal_Int32(pos
+ _length
) > m_aValue
.getLength() )
49 throw ::com::sun::star::sdbc::SQLException();
50 return ::com::sun::star::uno::Sequence
< ::sal_Int8
>(m_aValue
.getConstArray() + sal_Int32(pos
),_length
);
52 // -----------------------------------------------------------------------------
53 ::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
)
55 return new ::comphelper::SequenceInputStream(m_aValue
);
57 // -----------------------------------------------------------------------------
58 ::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
)
60 ::dbtools::throwFeatureNotImplementedException( "XBlob::position", *this );
63 // -----------------------------------------------------------------------------
64 ::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
)
66 ::dbtools::throwFeatureNotImplementedException( "XBlob::positionOfBlob", *this );
70 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */