1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <com/sun/star/sdbc/XResultSet.hpp>
23 #include <com/sun/star/sdbc/XRow.hpp>
24 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
25 #include <com/sun/star/sdbc/XCloseable.hpp>
26 #include <com/sun/star/sdbc/XColumnLocate.hpp>
27 #include <com/sun/star/util/XCancellable.hpp>
28 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
29 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
30 #include <com/sun/star/sdbcx/XRowLocate.hpp>
31 #include <com/sun/star/sdbcx/XDeleteRows.hpp>
32 #include <com/sun/star/sdbc/XRowUpdate.hpp>
33 #include <cppuhelper/compbase.hxx>
34 #include <comphelper/proparrhlp.hxx>
35 #include <ado/AStatement.hxx>
36 #include <cppuhelper/basemutex.hxx>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
39 namespace connectivity::ado
44 typedef ::cppu::WeakComponentImplHelper
< css::sdbc::XResultSet
,
46 css::sdbc::XResultSetMetaDataSupplier
,
47 css::util::XCancellable
,
48 css::sdbc::XWarningsSupplier
,
49 css::sdbc::XResultSetUpdate
,
50 css::sdbc::XRowUpdate
,
51 css::sdbc::XCloseable
,
52 css::sdbc::XColumnLocate
,
53 css::sdbcx::XRowLocate
,
54 css::sdbcx::XDeleteRows
,
55 css::lang::XServiceInfo
> OResultSet_BASE
;
57 class OResultSet
: public cppu::BaseMutex
,
58 public OResultSet_BASE
,
59 public ::cppu::OPropertySetHelper
,
60 public ::comphelper::OPropertyArrayUsageHelper
<OResultSet
>
63 ADORecordset
* m_pRecordSet
;
64 OStatement_Base
* m_pStmt
;
65 css::uno::Reference
< css::uno::XInterface
> m_xStatement
;
66 css::uno::Reference
< css::sdbc::XResultSetMetaData
> m_xMetaData
;
67 std::vector
<OLEVariant
> m_aBookmarks
;
71 bool m_bOnFirstAfterOpen
;
73 /// @throws css::sdbc::SQLException
74 /// @throws css::uno::RuntimeException
75 sal_Int32
getResultSetConcurrency() const;
76 /// @throws css::sdbc::SQLException
77 /// @throws css::uno::RuntimeException
78 sal_Int32
getResultSetType() const;
79 /// @throws css::sdbc::SQLException
80 /// @throws css::uno::RuntimeException
81 static sal_Int32
getFetchDirection();
82 /// @throws css::sdbc::SQLException
83 /// @throws css::uno::RuntimeException
84 sal_Int32
getFetchSize() const;
85 /// @throws css::sdbc::SQLException
86 /// @throws css::uno::RuntimeException
87 static OUString
getCursorName();
89 /// @throws css::sdbc::SQLException
90 /// @throws css::uno::RuntimeException
91 void setFetchDirection(sal_Int32 _par0
);
92 /// @throws css::sdbc::SQLException
93 /// @throws css::uno::RuntimeException
94 void setFetchSize(sal_Int32 _par0
);
95 void updateValue(sal_Int32 columnIndex
,const OLEVariant
& x
);
96 /// @throws css::sdbc::SQLException
97 /// @throws css::uno::RuntimeException
98 OLEVariant
getValue(sal_Int32 columnIndex
);
102 // OPropertyArrayUsageHelper
103 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const override
;
104 // OPropertySetHelper
105 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
106 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
107 css::uno::Any
& rConvertedValue
,
108 css::uno::Any
& rOldValue
,
110 const css::uno::Any
& rValue
) override
;
111 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
113 const css::uno::Any
& rValue
115 virtual void SAL_CALL
getFastPropertyValue(
116 css::uno::Any
& rValue
,
119 virtual ~OResultSet() override
;
121 // a Constructor, that is needed for when Returning the Object is needed:
122 OResultSet( ADORecordset
* _pRecordSet
,OStatement_Base
* pStmt
);
123 OResultSet( ADORecordset
* _pRecordSet
);
127 void setMetaData(const css::uno::Reference
< css::sdbc::XResultSetMetaData
>& _xMetaData
) { m_xMetaData
= _xMetaData
;}
129 virtual OUString SAL_CALL
getImplementationName( ) override
;
130 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
131 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
133 // ::cppu::OComponentHelper
134 virtual void SAL_CALL
disposing() override
;
136 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
137 virtual void SAL_CALL
acquire() noexcept override
;
138 virtual void SAL_CALL
release() noexcept override
;
140 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes( ) override
;
142 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
144 virtual sal_Bool SAL_CALL
next( ) override
;
145 virtual sal_Bool SAL_CALL
isBeforeFirst( ) override
;
146 virtual sal_Bool SAL_CALL
isAfterLast( ) override
;
147 virtual sal_Bool SAL_CALL
isFirst( ) override
;
148 virtual sal_Bool SAL_CALL
isLast( ) override
;
149 virtual void SAL_CALL
beforeFirst( ) override
;
150 virtual void SAL_CALL
afterLast( ) override
;
151 virtual sal_Bool SAL_CALL
first( ) override
;
152 virtual sal_Bool SAL_CALL
last( ) override
;
153 virtual sal_Int32 SAL_CALL
getRow( ) override
;
154 virtual sal_Bool SAL_CALL
absolute( sal_Int32 row
) override
;
155 virtual sal_Bool SAL_CALL
relative( sal_Int32 rows
) override
;
156 virtual sal_Bool SAL_CALL
previous( ) override
;
157 virtual void SAL_CALL
refreshRow( ) override
;
158 virtual sal_Bool SAL_CALL
rowUpdated( ) override
;
159 virtual sal_Bool SAL_CALL
rowInserted( ) override
;
160 virtual sal_Bool SAL_CALL
rowDeleted( ) override
;
161 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getStatement( ) override
;
163 virtual sal_Bool SAL_CALL
wasNull( ) override
;
164 virtual OUString SAL_CALL
getString( sal_Int32 columnIndex
) override
;
165 virtual sal_Bool SAL_CALL
getBoolean( sal_Int32 columnIndex
) override
;
166 virtual sal_Int8 SAL_CALL
getByte( sal_Int32 columnIndex
) override
;
167 virtual sal_Int16 SAL_CALL
getShort( sal_Int32 columnIndex
) override
;
168 virtual sal_Int32 SAL_CALL
getInt( sal_Int32 columnIndex
) override
;
169 virtual sal_Int64 SAL_CALL
getLong( sal_Int32 columnIndex
) override
;
170 virtual float SAL_CALL
getFloat( sal_Int32 columnIndex
) override
;
171 virtual double SAL_CALL
getDouble( sal_Int32 columnIndex
) override
;
172 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getBytes( sal_Int32 columnIndex
) override
;
173 virtual css::util::Date SAL_CALL
getDate( sal_Int32 columnIndex
) override
;
174 virtual css::util::Time SAL_CALL
getTime( sal_Int32 columnIndex
) override
;
175 virtual css::util::DateTime SAL_CALL
getTimestamp( sal_Int32 columnIndex
) override
;
176 virtual css::uno::Reference
< css::io::XInputStream
> SAL_CALL
getBinaryStream( sal_Int32 columnIndex
) override
;
177 virtual css::uno::Reference
< css::io::XInputStream
> SAL_CALL
getCharacterStream( sal_Int32 columnIndex
) override
;
178 virtual css::uno::Any SAL_CALL
getObject( sal_Int32 columnIndex
, const css::uno::Reference
< css::container::XNameAccess
>& typeMap
) override
;
179 virtual css::uno::Reference
< css::sdbc::XRef
> SAL_CALL
getRef( sal_Int32 columnIndex
) override
;
180 virtual css::uno::Reference
< css::sdbc::XBlob
> SAL_CALL
getBlob( sal_Int32 columnIndex
) override
;
181 virtual css::uno::Reference
< css::sdbc::XClob
> SAL_CALL
getClob( sal_Int32 columnIndex
) override
;
182 virtual css::uno::Reference
< css::sdbc::XArray
> SAL_CALL
getArray( sal_Int32 columnIndex
) override
;
183 // XResultSetMetaDataSupplier
184 virtual css::uno::Reference
< css::sdbc::XResultSetMetaData
> SAL_CALL
getMetaData( ) override
;
186 virtual void SAL_CALL
cancel( ) override
;
188 virtual void SAL_CALL
close( ) override
;
190 virtual css::uno::Any SAL_CALL
getWarnings( ) override
;
191 virtual void SAL_CALL
clearWarnings( ) override
;
193 virtual void SAL_CALL
insertRow( ) override
;
194 virtual void SAL_CALL
updateRow( ) override
;
195 virtual void SAL_CALL
deleteRow( ) override
;
196 virtual void SAL_CALL
cancelRowUpdates( ) override
;
197 virtual void SAL_CALL
moveToInsertRow( ) override
;
198 virtual void SAL_CALL
moveToCurrentRow( ) override
;
200 virtual void SAL_CALL
updateNull( sal_Int32 columnIndex
) override
;
201 virtual void SAL_CALL
updateBoolean( sal_Int32 columnIndex
, sal_Bool x
) override
;
202 virtual void SAL_CALL
updateByte( sal_Int32 columnIndex
, sal_Int8 x
) override
;
203 virtual void SAL_CALL
updateShort( sal_Int32 columnIndex
, sal_Int16 x
) override
;
204 virtual void SAL_CALL
updateInt( sal_Int32 columnIndex
, sal_Int32 x
) override
;
205 virtual void SAL_CALL
updateLong( sal_Int32 columnIndex
, sal_Int64 x
) override
;
206 virtual void SAL_CALL
updateFloat( sal_Int32 columnIndex
, float x
) override
;
207 virtual void SAL_CALL
updateDouble( sal_Int32 columnIndex
, double x
) override
;
208 virtual void SAL_CALL
updateString( sal_Int32 columnIndex
, const OUString
& x
) override
;
209 virtual void SAL_CALL
updateBytes( sal_Int32 columnIndex
, const css::uno::Sequence
< sal_Int8
>& x
) override
;
210 virtual void SAL_CALL
updateDate( sal_Int32 columnIndex
, const css::util::Date
& x
) override
;
211 virtual void SAL_CALL
updateTime( sal_Int32 columnIndex
, const css::util::Time
& x
) override
;
212 virtual void SAL_CALL
updateTimestamp( sal_Int32 columnIndex
, const css::util::DateTime
& x
) override
;
213 virtual void SAL_CALL
updateBinaryStream( sal_Int32 columnIndex
, const css::uno::Reference
< css::io::XInputStream
>& x
, sal_Int32 length
) override
;
214 virtual void SAL_CALL
updateCharacterStream( sal_Int32 columnIndex
, const css::uno::Reference
< css::io::XInputStream
>& x
, sal_Int32 length
) override
;
215 virtual void SAL_CALL
updateObject( sal_Int32 columnIndex
, const css::uno::Any
& x
) override
;
216 virtual void SAL_CALL
updateNumericObject( sal_Int32 columnIndex
, const css::uno::Any
& x
, sal_Int32 scale
) override
;
218 virtual sal_Int32 SAL_CALL
findColumn( const OUString
& columnName
) override
;
220 virtual css::uno::Any SAL_CALL
getBookmark( ) override
;
221 virtual sal_Bool SAL_CALL
moveToBookmark( const css::uno::Any
& bookmark
) override
;
222 virtual sal_Bool SAL_CALL
moveRelativeToBookmark( const css::uno::Any
& bookmark
, sal_Int32 rows
) override
;
223 virtual sal_Int32 SAL_CALL
compareBookmarks( const css::uno::Any
& first
, const css::uno::Any
& second
) override
;
224 virtual sal_Bool SAL_CALL
hasOrderedBookmarks( ) override
;
225 virtual sal_Int32 SAL_CALL
hashBookmark( const css::uno::Any
& bookmark
) override
;
227 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
deleteRows( const css::uno::Sequence
< css::uno::Any
>& rows
) override
;
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */