1*9b5730f6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9b5730f6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9b5730f6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9b5730f6SAndrew Rist * distributed with this work for additional information 6*9b5730f6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9b5730f6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9b5730f6SAndrew Rist * "License"); you may not use this file except in compliance 9*9b5730f6SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9b5730f6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9b5730f6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9b5730f6SAndrew Rist * software distributed under the License is distributed on an 15*9b5730f6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9b5730f6SAndrew Rist * KIND, either express or implied. See the License for the 17*9b5730f6SAndrew Rist * specific language governing permissions and limitations 18*9b5730f6SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9b5730f6SAndrew Rist *************************************************************/ 21*9b5730f6SAndrew Rist 22*9b5730f6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_connectivity.hxx" 26cdf0e10cSrcweir #include <com/sun/star/sdbcx/CompareBookmark.hpp> 27cdf0e10cSrcweir #include "calc/CResultSet.hxx" 28cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 29cdf0e10cSrcweir #include <comphelper/sequence.hxx> 30cdf0e10cSrcweir #include <comphelper/types.hxx> 31cdf0e10cSrcweir #include <connectivity/dbexception.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir using namespace ::comphelper; 34cdf0e10cSrcweir using namespace connectivity::calc; 35cdf0e10cSrcweir using namespace connectivity::file; 36cdf0e10cSrcweir using namespace ::cppu; 37cdf0e10cSrcweir using namespace com::sun::star::uno; 38cdf0e10cSrcweir using namespace com::sun::star::lang; 39cdf0e10cSrcweir using namespace com::sun::star::beans; 40cdf0e10cSrcweir using namespace com::sun::star::sdbc; 41cdf0e10cSrcweir using namespace com::sun::star::sdbcx; 42cdf0e10cSrcweir // using namespace com::sun::star::container; 43cdf0e10cSrcweir // using namespace com::sun::star::util; 44cdf0e10cSrcweir //------------------------------------------------------------------------------ 45cdf0e10cSrcweir OCalcResultSet::OCalcResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator) 46cdf0e10cSrcweir : file::OResultSet(pStmt,_aSQLIterator) 47cdf0e10cSrcweir ,m_bBookmarkable(sal_True) 48cdf0e10cSrcweir { 49cdf0e10cSrcweir registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), PROPERTY_ID_ISBOOKMARKABLE, PropertyAttribute::READONLY,&m_bBookmarkable, ::getBooleanCppuType()); 50cdf0e10cSrcweir } 51cdf0e10cSrcweir // ------------------------------------------------------------------------- 52cdf0e10cSrcweir ::rtl::OUString SAL_CALL OCalcResultSet::getImplementationName( ) throw ( RuntimeException) 53cdf0e10cSrcweir { 54cdf0e10cSrcweir return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.calc.ResultSet"); 55cdf0e10cSrcweir } 56cdf0e10cSrcweir // ------------------------------------------------------------------------- 57cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL OCalcResultSet::getSupportedServiceNames( ) throw( RuntimeException) 58cdf0e10cSrcweir { 59cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported(2); 60cdf0e10cSrcweir aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet"); 61cdf0e10cSrcweir aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ResultSet"); 62cdf0e10cSrcweir return aSupported; 63cdf0e10cSrcweir } 64cdf0e10cSrcweir // ------------------------------------------------------------------------- 65cdf0e10cSrcweir sal_Bool SAL_CALL OCalcResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); 68cdf0e10cSrcweir const ::rtl::OUString* pSupported = aSupported.getConstArray(); 69cdf0e10cSrcweir const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); 70cdf0e10cSrcweir for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported) 71cdf0e10cSrcweir ; 72cdf0e10cSrcweir 73cdf0e10cSrcweir return pSupported != pEnd; 74cdf0e10cSrcweir } 75cdf0e10cSrcweir // ------------------------------------------------------------------------- 76cdf0e10cSrcweir Any SAL_CALL OCalcResultSet::queryInterface( const Type & rType ) throw(RuntimeException) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir Any aRet = OResultSet::queryInterface(rType); 79cdf0e10cSrcweir return aRet.hasValue() ? aRet : OCalcResultSet_BASE::queryInterface(rType); 80cdf0e10cSrcweir } 81cdf0e10cSrcweir // ------------------------------------------------------------------------- 82cdf0e10cSrcweir Sequence< Type > SAL_CALL OCalcResultSet::getTypes( ) throw( RuntimeException) 83cdf0e10cSrcweir { 84cdf0e10cSrcweir return ::comphelper::concatSequences(OResultSet::getTypes(),OCalcResultSet_BASE::getTypes()); 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir // ------------------------------------------------------------------------- 88cdf0e10cSrcweir // XRowLocate 89cdf0e10cSrcweir Any SAL_CALL OCalcResultSet::getBookmark( ) throw( SQLException, RuntimeException) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 92cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 93cdf0e10cSrcweir 94cdf0e10cSrcweir 95cdf0e10cSrcweir return makeAny((sal_Int32)(m_aRow->get())[0]->getValue()); 96cdf0e10cSrcweir } 97cdf0e10cSrcweir // ------------------------------------------------------------------------- 98cdf0e10cSrcweir sal_Bool SAL_CALL OCalcResultSet::moveToBookmark( const Any& bookmark ) throw( SQLException, RuntimeException) 99cdf0e10cSrcweir { 100cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 101cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 102cdf0e10cSrcweir 103cdf0e10cSrcweir 104cdf0e10cSrcweir m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False; 105cdf0e10cSrcweir 106cdf0e10cSrcweir return Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),sal_True); 107cdf0e10cSrcweir } 108cdf0e10cSrcweir // ------------------------------------------------------------------------- 109cdf0e10cSrcweir sal_Bool SAL_CALL OCalcResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 112cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 113cdf0e10cSrcweir 114cdf0e10cSrcweir 115cdf0e10cSrcweir m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False; 116cdf0e10cSrcweir 117cdf0e10cSrcweir Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),sal_False); 118cdf0e10cSrcweir 119cdf0e10cSrcweir return relative(rows); 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir // ------------------------------------------------------------------------- 123cdf0e10cSrcweir sal_Int32 SAL_CALL OCalcResultSet::compareBookmarks( const Any& lhs, const Any& rhs ) throw( SQLException, RuntimeException) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir return (lhs == rhs) ? 0 : 2; 126cdf0e10cSrcweir } 127cdf0e10cSrcweir // ------------------------------------------------------------------------- 128cdf0e10cSrcweir sal_Bool SAL_CALL OCalcResultSet::hasOrderedBookmarks( ) throw( SQLException, RuntimeException) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir return sal_True; 131cdf0e10cSrcweir } 132cdf0e10cSrcweir // ------------------------------------------------------------------------- 133cdf0e10cSrcweir sal_Int32 SAL_CALL OCalcResultSet::hashBookmark( const Any& bookmark ) throw( SQLException, RuntimeException) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 136cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 137cdf0e10cSrcweir 138cdf0e10cSrcweir 139cdf0e10cSrcweir return comphelper::getINT32(bookmark); 140cdf0e10cSrcweir } 141cdf0e10cSrcweir // ------------------------------------------------------------------------- 142cdf0e10cSrcweir // XDeleteRows 143cdf0e10cSrcweir Sequence< sal_Int32 > SAL_CALL OCalcResultSet::deleteRows( const Sequence< Any >& /*rows*/ ) throw( SQLException, RuntimeException) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 146cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 147cdf0e10cSrcweir 148cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "XDeleteRows::deleteRows", *this ); 149cdf0e10cSrcweir return Sequence< sal_Int32 >(); 150cdf0e10cSrcweir } 151cdf0e10cSrcweir // ------------------------------------------------------------------------- 152cdf0e10cSrcweir sal_Bool OCalcResultSet::fillIndexValues(const Reference< XColumnsSupplier> &/*_xIndex*/) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir // Calc table has no index 155cdf0e10cSrcweir return sal_False; 156cdf0e10cSrcweir } 157cdf0e10cSrcweir // ------------------------------------------------------------------------- 158cdf0e10cSrcweir ::cppu::IPropertyArrayHelper & OCalcResultSet::getInfoHelper() 159cdf0e10cSrcweir { 160cdf0e10cSrcweir return *OCalcResultSet_BASE3::getArrayHelper(); 161cdf0e10cSrcweir } 162cdf0e10cSrcweir // ----------------------------------------------------------------------------- 163cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* OCalcResultSet::createArrayHelper() const 164cdf0e10cSrcweir { 165cdf0e10cSrcweir Sequence< Property > aProps; 166cdf0e10cSrcweir describeProperties(aProps); 167cdf0e10cSrcweir return new ::cppu::OPropertyArrayHelper(aProps); 168cdf0e10cSrcweir } 169cdf0e10cSrcweir // ------------------------------------------------------------------------- 170cdf0e10cSrcweir // ----------------------------------------------------------------------------- 171cdf0e10cSrcweir void SAL_CALL OCalcResultSet::acquire() throw() 172cdf0e10cSrcweir { 173cdf0e10cSrcweir OCalcResultSet_BASE2::acquire(); 174cdf0e10cSrcweir } 175cdf0e10cSrcweir // ----------------------------------------------------------------------------- 176cdf0e10cSrcweir void SAL_CALL OCalcResultSet::release() throw() 177cdf0e10cSrcweir { 178cdf0e10cSrcweir OCalcResultSet_BASE2::release(); 179cdf0e10cSrcweir } 180cdf0e10cSrcweir // ----------------------------------------------------------------------------- 181cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OCalcResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) 182cdf0e10cSrcweir { 183cdf0e10cSrcweir return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); 184cdf0e10cSrcweir } 185cdf0e10cSrcweir // ----------------------------------------------------------------------------- 186cdf0e10cSrcweir 187cdf0e10cSrcweir 188