Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / calc / CResultSet.cxx
blobe0748bb83c889c5a1488c253788260c4863cb3d9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/sdbcx/CompareBookmark.hpp>
21 #include "calc/CResultSet.hxx"
22 #include <com/sun/star/lang/DisposedException.hpp>
23 #include <comphelper/sequence.hxx>
24 #include <comphelper/types.hxx>
25 #include <cppuhelper/supportsservice.hxx>
26 #include <connectivity/dbexception.hxx>
28 using namespace ::comphelper;
29 using namespace connectivity::calc;
30 using namespace connectivity::file;
31 using namespace ::cppu;
32 using namespace com::sun::star::uno;
33 using namespace com::sun::star::lang;
34 using namespace com::sun::star::beans;
35 using namespace com::sun::star::sdbc;
36 using namespace com::sun::star::sdbcx;
39 OCalcResultSet::OCalcResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator)
40 : file::OResultSet(pStmt,_aSQLIterator)
41 ,m_bBookmarkable(true)
43 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), PROPERTY_ID_ISBOOKMARKABLE, PropertyAttribute::READONLY,&m_bBookmarkable, ::getBooleanCppuType());
46 OUString SAL_CALL OCalcResultSet::getImplementationName( ) throw ( RuntimeException, std::exception)
48 return OUString("com.sun.star.sdbcx.calc.ResultSet");
51 Sequence< OUString > SAL_CALL OCalcResultSet::getSupportedServiceNames( ) throw( RuntimeException, std::exception)
53 Sequence< OUString > aSupported(2);
54 aSupported[0] = "com.sun.star.sdbc.ResultSet";
55 aSupported[1] = "com.sun.star.sdbcx.ResultSet";
56 return aSupported;
59 sal_Bool SAL_CALL OCalcResultSet::supportsService( const OUString& _rServiceName ) throw( RuntimeException, std::exception)
61 return cppu::supportsService(this, _rServiceName);
64 Any SAL_CALL OCalcResultSet::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
66 Any aRet = OResultSet::queryInterface(rType);
67 return aRet.hasValue() ? aRet : OCalcResultSet_BASE::queryInterface(rType);
70 Sequence< Type > SAL_CALL OCalcResultSet::getTypes( ) throw( RuntimeException, std::exception)
72 return ::comphelper::concatSequences(OResultSet::getTypes(),OCalcResultSet_BASE::getTypes());
76 // XRowLocate
77 Any SAL_CALL OCalcResultSet::getBookmark( ) throw( SQLException, RuntimeException, std::exception)
79 ::osl::MutexGuard aGuard( m_aMutex );
80 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
83 return makeAny((sal_Int32)(m_aRow->get())[0]->getValue());
86 sal_Bool SAL_CALL OCalcResultSet::moveToBookmark( const Any& bookmark ) throw( SQLException, RuntimeException, std::exception)
88 ::osl::MutexGuard aGuard( m_aMutex );
89 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
92 m_bRowDeleted = m_bRowInserted = m_bRowUpdated = false;
94 return Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),true);
97 sal_Bool SAL_CALL OCalcResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException, std::exception)
99 ::osl::MutexGuard aGuard( m_aMutex );
100 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
103 m_bRowDeleted = m_bRowInserted = m_bRowUpdated = false;
105 Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),false);
107 return relative(rows);
111 sal_Int32 SAL_CALL OCalcResultSet::compareBookmarks( const Any& lhs, const Any& rhs ) throw( SQLException, RuntimeException, std::exception)
113 return (lhs == rhs) ? 0 : 2;
116 sal_Bool SAL_CALL OCalcResultSet::hasOrderedBookmarks( ) throw( SQLException, RuntimeException, std::exception)
118 return sal_True;
121 sal_Int32 SAL_CALL OCalcResultSet::hashBookmark( const Any& bookmark ) throw( SQLException, RuntimeException, std::exception)
123 ::osl::MutexGuard aGuard( m_aMutex );
124 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
127 return comphelper::getINT32(bookmark);
130 // XDeleteRows
131 Sequence< sal_Int32 > SAL_CALL OCalcResultSet::deleteRows( const Sequence< Any >& /*rows*/ ) throw( SQLException, RuntimeException, std::exception)
133 ::osl::MutexGuard aGuard( m_aMutex );
134 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
136 ::dbtools::throwFeatureNotImplementedException( "XDeleteRows::deleteRows", *this );
137 return Sequence< sal_Int32 >();
140 bool OCalcResultSet::fillIndexValues(const Reference< XColumnsSupplier> &/*_xIndex*/)
142 // Calc table has no index
143 return false;
146 ::cppu::IPropertyArrayHelper & OCalcResultSet::getInfoHelper()
148 return *OCalcResultSet_BASE3::getArrayHelper();
151 ::cppu::IPropertyArrayHelper* OCalcResultSet::createArrayHelper() const
153 Sequence< Property > aProps;
154 describeProperties(aProps);
155 return new ::cppu::OPropertyArrayHelper(aProps);
159 void SAL_CALL OCalcResultSet::acquire() throw()
161 OCalcResultSet_BASE2::acquire();
164 void SAL_CALL OCalcResultSet::release() throw()
166 OCalcResultSet_BASE2::release();
169 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OCalcResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
171 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */