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