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 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_connectivity.hxx" 30 #include <com/sun/star/sdbcx/CompareBookmark.hpp> 31 #include "calc/CResultSet.hxx" 32 #include <com/sun/star/lang/DisposedException.hpp> 33 #include <comphelper/sequence.hxx> 34 #include <comphelper/types.hxx> 35 #include <connectivity/dbexception.hxx> 36 37 using namespace ::comphelper; 38 using namespace connectivity::calc; 39 using namespace connectivity::file; 40 using namespace ::cppu; 41 using namespace com::sun::star::uno; 42 using namespace com::sun::star::lang; 43 using namespace com::sun::star::beans; 44 using namespace com::sun::star::sdbc; 45 using namespace com::sun::star::sdbcx; 46 // using namespace com::sun::star::container; 47 // using namespace com::sun::star::util; 48 //------------------------------------------------------------------------------ 49 OCalcResultSet::OCalcResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator) 50 : file::OResultSet(pStmt,_aSQLIterator) 51 ,m_bBookmarkable(sal_True) 52 { 53 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), PROPERTY_ID_ISBOOKMARKABLE, PropertyAttribute::READONLY,&m_bBookmarkable, ::getBooleanCppuType()); 54 } 55 // ------------------------------------------------------------------------- 56 ::rtl::OUString SAL_CALL OCalcResultSet::getImplementationName( ) throw ( RuntimeException) 57 { 58 return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.calc.ResultSet"); 59 } 60 // ------------------------------------------------------------------------- 61 Sequence< ::rtl::OUString > SAL_CALL OCalcResultSet::getSupportedServiceNames( ) throw( RuntimeException) 62 { 63 Sequence< ::rtl::OUString > aSupported(2); 64 aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet"); 65 aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ResultSet"); 66 return aSupported; 67 } 68 // ------------------------------------------------------------------------- 69 sal_Bool SAL_CALL OCalcResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException) 70 { 71 Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); 72 const ::rtl::OUString* pSupported = aSupported.getConstArray(); 73 const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); 74 for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported) 75 ; 76 77 return pSupported != pEnd; 78 } 79 // ------------------------------------------------------------------------- 80 Any SAL_CALL OCalcResultSet::queryInterface( const Type & rType ) throw(RuntimeException) 81 { 82 Any aRet = OResultSet::queryInterface(rType); 83 return aRet.hasValue() ? aRet : OCalcResultSet_BASE::queryInterface(rType); 84 } 85 // ------------------------------------------------------------------------- 86 Sequence< Type > SAL_CALL OCalcResultSet::getTypes( ) throw( RuntimeException) 87 { 88 return ::comphelper::concatSequences(OResultSet::getTypes(),OCalcResultSet_BASE::getTypes()); 89 } 90 91 // ------------------------------------------------------------------------- 92 // XRowLocate 93 Any SAL_CALL OCalcResultSet::getBookmark( ) throw( SQLException, RuntimeException) 94 { 95 ::osl::MutexGuard aGuard( m_aMutex ); 96 checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 97 98 99 return makeAny((sal_Int32)(m_aRow->get())[0]->getValue()); 100 } 101 // ------------------------------------------------------------------------- 102 sal_Bool SAL_CALL OCalcResultSet::moveToBookmark( const Any& bookmark ) throw( SQLException, RuntimeException) 103 { 104 ::osl::MutexGuard aGuard( m_aMutex ); 105 checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 106 107 108 m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False; 109 110 return Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),sal_True); 111 } 112 // ------------------------------------------------------------------------- 113 sal_Bool SAL_CALL OCalcResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException) 114 { 115 ::osl::MutexGuard aGuard( m_aMutex ); 116 checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 117 118 119 m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False; 120 121 Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),sal_False); 122 123 return relative(rows); 124 } 125 126 // ------------------------------------------------------------------------- 127 sal_Int32 SAL_CALL OCalcResultSet::compareBookmarks( const Any& lhs, const Any& rhs ) throw( SQLException, RuntimeException) 128 { 129 return (lhs == rhs) ? 0 : 2; 130 } 131 // ------------------------------------------------------------------------- 132 sal_Bool SAL_CALL OCalcResultSet::hasOrderedBookmarks( ) throw( SQLException, RuntimeException) 133 { 134 return sal_True; 135 } 136 // ------------------------------------------------------------------------- 137 sal_Int32 SAL_CALL OCalcResultSet::hashBookmark( const Any& bookmark ) throw( SQLException, RuntimeException) 138 { 139 ::osl::MutexGuard aGuard( m_aMutex ); 140 checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 141 142 143 return comphelper::getINT32(bookmark); 144 } 145 // ------------------------------------------------------------------------- 146 // XDeleteRows 147 Sequence< sal_Int32 > SAL_CALL OCalcResultSet::deleteRows( const Sequence< Any >& /*rows*/ ) throw( SQLException, RuntimeException) 148 { 149 ::osl::MutexGuard aGuard( m_aMutex ); 150 checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 151 152 ::dbtools::throwFeatureNotImplementedException( "XDeleteRows::deleteRows", *this ); 153 return Sequence< sal_Int32 >(); 154 } 155 // ------------------------------------------------------------------------- 156 sal_Bool OCalcResultSet::fillIndexValues(const Reference< XColumnsSupplier> &/*_xIndex*/) 157 { 158 // Calc table has no index 159 return sal_False; 160 } 161 // ------------------------------------------------------------------------- 162 ::cppu::IPropertyArrayHelper & OCalcResultSet::getInfoHelper() 163 { 164 return *OCalcResultSet_BASE3::getArrayHelper(); 165 } 166 // ----------------------------------------------------------------------------- 167 ::cppu::IPropertyArrayHelper* OCalcResultSet::createArrayHelper() const 168 { 169 Sequence< Property > aProps; 170 describeProperties(aProps); 171 return new ::cppu::OPropertyArrayHelper(aProps); 172 } 173 // ------------------------------------------------------------------------- 174 // ----------------------------------------------------------------------------- 175 void SAL_CALL OCalcResultSet::acquire() throw() 176 { 177 OCalcResultSet_BASE2::acquire(); 178 } 179 // ----------------------------------------------------------------------------- 180 void SAL_CALL OCalcResultSet::release() throw() 181 { 182 OCalcResultSet_BASE2::release(); 183 } 184 // ----------------------------------------------------------------------------- 185 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OCalcResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) 186 { 187 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); 188 } 189 // ----------------------------------------------------------------------------- 190 191 192