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