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