Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
27 :
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;
37 :
38 :
39 8 : OCalcResultSet::OCalcResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator)
40 : : file::OResultSet(pStmt,_aSQLIterator)
41 8 : ,m_bBookmarkable(true)
42 : {
43 8 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), PROPERTY_ID_ISBOOKMARKABLE, PropertyAttribute::READONLY,&m_bBookmarkable, cppu::UnoType<bool>::get());
44 8 : }
45 :
46 0 : OUString SAL_CALL OCalcResultSet::getImplementationName( ) throw ( RuntimeException, std::exception)
47 : {
48 0 : return OUString("com.sun.star.sdbcx.calc.ResultSet");
49 : }
50 :
51 0 : Sequence< OUString > SAL_CALL OCalcResultSet::getSupportedServiceNames( ) throw( RuntimeException, std::exception)
52 : {
53 0 : Sequence< OUString > aSupported(2);
54 0 : aSupported[0] = "com.sun.star.sdbc.ResultSet";
55 0 : aSupported[1] = "com.sun.star.sdbcx.ResultSet";
56 0 : return aSupported;
57 : }
58 :
59 0 : sal_Bool SAL_CALL OCalcResultSet::supportsService( const OUString& _rServiceName ) throw( RuntimeException, std::exception)
60 : {
61 0 : return cppu::supportsService(this, _rServiceName);
62 : }
63 :
64 541 : Any SAL_CALL OCalcResultSet::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
65 : {
66 541 : Any aRet = OResultSet::queryInterface(rType);
67 541 : return aRet.hasValue() ? aRet : OCalcResultSet_BASE::queryInterface(rType);
68 : }
69 :
70 0 : Sequence< Type > SAL_CALL OCalcResultSet::getTypes( ) throw( RuntimeException, std::exception)
71 : {
72 0 : return ::comphelper::concatSequences(OResultSet::getTypes(),OCalcResultSet_BASE::getTypes());
73 : }
74 :
75 :
76 : // XRowLocate
77 64 : Any SAL_CALL OCalcResultSet::getBookmark( ) throw( SQLException, RuntimeException, std::exception)
78 : {
79 64 : ::osl::MutexGuard aGuard( m_aMutex );
80 64 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
81 :
82 :
83 64 : return makeAny((sal_Int32)(m_aRow->get())[0]->getValue());
84 : }
85 :
86 0 : sal_Bool SAL_CALL OCalcResultSet::moveToBookmark( const Any& bookmark ) throw( SQLException, RuntimeException, std::exception)
87 : {
88 0 : ::osl::MutexGuard aGuard( m_aMutex );
89 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
90 :
91 :
92 0 : m_bRowDeleted = m_bRowInserted = m_bRowUpdated = false;
93 :
94 0 : return Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),true);
95 : }
96 :
97 0 : sal_Bool SAL_CALL OCalcResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException, std::exception)
98 : {
99 0 : ::osl::MutexGuard aGuard( m_aMutex );
100 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
101 :
102 :
103 0 : m_bRowDeleted = m_bRowInserted = m_bRowUpdated = false;
104 :
105 0 : Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),false);
106 :
107 0 : return relative(rows);
108 : }
109 :
110 :
111 373 : sal_Int32 SAL_CALL OCalcResultSet::compareBookmarks( const Any& lhs, const Any& rhs ) throw( SQLException, RuntimeException, std::exception)
112 : {
113 373 : return (lhs == rhs) ? CompareBookmark::EQUAL : CompareBookmark::NOT_EQUAL;
114 : }
115 :
116 0 : sal_Bool SAL_CALL OCalcResultSet::hasOrderedBookmarks( ) throw( SQLException, RuntimeException, std::exception)
117 : {
118 0 : return sal_True;
119 : }
120 :
121 0 : sal_Int32 SAL_CALL OCalcResultSet::hashBookmark( const Any& bookmark ) throw( SQLException, RuntimeException, std::exception)
122 : {
123 0 : ::osl::MutexGuard aGuard( m_aMutex );
124 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
125 :
126 :
127 0 : return comphelper::getINT32(bookmark);
128 : }
129 :
130 : // XDeleteRows
131 0 : Sequence< sal_Int32 > SAL_CALL OCalcResultSet::deleteRows( const Sequence< Any >& /*rows*/ ) throw( SQLException, RuntimeException, std::exception)
132 : {
133 0 : ::osl::MutexGuard aGuard( m_aMutex );
134 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
135 :
136 0 : ::dbtools::throwFeatureNotImplementedSQLException( "XDeleteRows::deleteRows", *this );
137 0 : return Sequence< sal_Int32 >();
138 : }
139 :
140 0 : bool OCalcResultSet::fillIndexValues(const Reference< XColumnsSupplier> &/*_xIndex*/)
141 : {
142 : // Calc table has no index
143 0 : return false;
144 : }
145 :
146 88 : ::cppu::IPropertyArrayHelper & OCalcResultSet::getInfoHelper()
147 : {
148 88 : return *OCalcResultSet_BASE3::getArrayHelper();
149 : }
150 :
151 8 : ::cppu::IPropertyArrayHelper* OCalcResultSet::createArrayHelper() const
152 : {
153 8 : Sequence< Property > aProps;
154 8 : describeProperties(aProps);
155 8 : return new ::cppu::OPropertyArrayHelper(aProps);
156 : }
157 :
158 :
159 765 : void SAL_CALL OCalcResultSet::acquire() throw()
160 : {
161 765 : OCalcResultSet_BASE2::acquire();
162 765 : }
163 :
164 765 : void SAL_CALL OCalcResultSet::release() throw()
165 : {
166 765 : OCalcResultSet_BASE2::release();
167 765 : }
168 :
169 8 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OCalcResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
170 : {
171 8 : return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
172 : }
173 :
174 :
175 :
176 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|