1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 // MARKER(update_precomp.py): autogen include statement, do not remove 28 #include "precompiled_connectivity.hxx" 29 #include "connectivity/BlobHelper.hxx" 30 #include <comphelper/seqstream.hxx> 31 #include "connectivity/dbexception.hxx" 32 33 using namespace connectivity; 34 using namespace dbtools; 35 using namespace ::com::sun::star::sdbc; 36 using namespace ::com::sun::star::uno; 37 38 BlobHelper::BlobHelper(const ::com::sun::star::uno::Sequence< sal_Int8 >& _val) : m_aValue(_val) 39 { 40 } 41 // ----------------------------------------------------------------------------- 42 ::sal_Int64 SAL_CALL BlobHelper::length( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 43 { 44 return m_aValue.getLength(); 45 } 46 // ----------------------------------------------------------------------------- 47 ::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 { 49 if ( sal_Int32(pos + _length) > m_aValue.getLength() ) 50 throw ::com::sun::star::sdbc::SQLException(); 51 return ::com::sun::star::uno::Sequence< ::sal_Int8 >(m_aValue.getConstArray() + sal_Int32(pos),_length); 52 } 53 // ----------------------------------------------------------------------------- 54 ::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 { 56 return new ::comphelper::SequenceInputStream(m_aValue); 57 } 58 // ----------------------------------------------------------------------------- 59 ::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 { 61 ::dbtools::throwFeatureNotImplementedException( "XBlob::position", *this ); 62 return 0; 63 } 64 // ----------------------------------------------------------------------------- 65 ::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 { 67 ::dbtools::throwFeatureNotImplementedException( "XBlob::positionOfBlob", *this ); 68 return 0; 69 } 70