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/sdbc/XRowUpdate.hpp>
31 #include <cppuhelper/compbase.hxx>
32 #include <cppuhelper/basemutex.hxx>
33 #include <comphelper/proparrhlp.hxx>
34 #include <ado/AStatement.hxx>
36 namespace connectivity::ado
41 typedef ::cppu::WeakComponentImplHelper
< css::sdbc::XResultSet
,
43 css::sdbc::XResultSetMetaDataSupplier
,
44 css::util::XCancellable
,
45 css::sdbc::XWarningsSupplier
,
46 css::sdbc::XCloseable
,
47 css::sdbc::XColumnLocate
> ODatabaseMetaDataResultSet_BASE
;
49 class ODatabaseMetaDataResultSet
: public cppu::BaseMutex
,
50 public ODatabaseMetaDataResultSet_BASE
,
51 public ::cppu::OPropertySetHelper
,
52 public ::comphelper::OPropertyArrayUsageHelper
<ODatabaseMetaDataResultSet
>
54 std::vector
<sal_Int32
> m_aColMapping
; // pos 0 is unused so we don't have to decrement 1 every time
56 std::map
<sal_Int32
, ::std::map
<sal_Int32
,sal_Int32
> > m_aValueRange
;
57 std::map
<sal_Int32
, ::std::map
<sal_Int32
,sal_Int32
> >::iterator m_aValueRangeIter
;
59 std::map
<sal_Int32
, std::map
< OUString
,sal_Int32
> > m_aStrValueRange
;
60 std::map
<sal_Int32
, std::map
< OUString
,sal_Int32
> >::iterator m_aStrValueRangeIter
;
62 std::map
<sal_Int32
, std::map
< sal_Int32
,OUString
> > m_aIntValueRange
;
63 std::map
<sal_Int32
, std::map
< sal_Int32
,OUString
> >::iterator m_aIntValueRangeIter
;
65 ADORecordset
* m_pRecordSet
;
66 css::uno::WeakReferenceHelper m_aStatement
;
67 css::uno::Reference
< css::sdbc::XResultSetMetaData
> m_xMetaData
;
72 bool m_bOnFirstAfterOpen
;
74 /// @throws css::sdbc::SQLException
75 /// @throws css::uno::RuntimeException
76 static sal_Int32
getResultSetConcurrency();
77 /// @throws css::sdbc::SQLException
78 /// @throws css::uno::RuntimeException
79 static sal_Int32
getResultSetType();
80 /// @throws css::sdbc::SQLException
81 /// @throws css::uno::RuntimeException
82 static sal_Int32
getFetchDirection();
83 /// @throws css::sdbc::SQLException
84 /// @throws css::uno::RuntimeException
85 sal_Int32
getFetchSize() const;
86 /// @throws css::sdbc::SQLException
87 /// @throws css::uno::RuntimeException
88 static OUString
getCursorName();
90 /// @throws css::sdbc::SQLException
91 /// @throws css::uno::RuntimeException
92 void setFetchDirection(sal_Int32 _par0
);
93 /// @throws css::sdbc::SQLException
94 /// @throws css::uno::RuntimeException
95 void setFetchSize(sal_Int32 _par0
);
98 inline sal_Int32
mapColumn (sal_Int32 column
);
99 /// @throws css::sdbc::SQLException
100 void checkRecordSet();
101 /// @throws css::sdbc::SQLException
102 /// @throws css::uno::RuntimeException
103 OLEVariant
getValue(sal_Int32 columnIndex
);
107 // OPropertyArrayUsageHelper
108 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const override
;
109 // OPropertySetHelper
110 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
112 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
113 css::uno::Any
& rConvertedValue
,
114 css::uno::Any
& rOldValue
,
116 const css::uno::Any
& rValue
) override
;
117 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
119 const css::uno::Any
& rValue
121 virtual void SAL_CALL
getFastPropertyValue(
122 css::uno::Any
& rValue
,
126 // a Constructor, that is needed for when Returning the Object is needed:
127 ODatabaseMetaDataResultSet( ADORecordset
* _pRecordSet
);
128 ~ODatabaseMetaDataResultSet() override
;
130 // ::cppu::OComponentHelper
131 virtual void SAL_CALL
disposing() override
;
133 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
134 virtual void SAL_CALL
acquire() noexcept override
;
135 virtual void SAL_CALL
release() noexcept override
;
137 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes( ) override
;
139 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
141 virtual sal_Bool SAL_CALL
next( ) override
;
142 virtual sal_Bool SAL_CALL
isBeforeFirst( ) override
;
143 virtual sal_Bool SAL_CALL
isAfterLast( ) override
;
144 virtual sal_Bool SAL_CALL
isFirst( ) override
;
145 virtual sal_Bool SAL_CALL
isLast( ) override
;
146 virtual void SAL_CALL
beforeFirst( ) override
;
147 virtual void SAL_CALL
afterLast( ) override
;
148 virtual sal_Bool SAL_CALL
first( ) override
;
149 virtual sal_Bool SAL_CALL
last( ) override
;
150 virtual sal_Int32 SAL_CALL
getRow( ) override
;
151 virtual sal_Bool SAL_CALL
absolute( sal_Int32 row
) override
;
152 virtual sal_Bool SAL_CALL
relative( sal_Int32 rows
) override
;
153 virtual sal_Bool SAL_CALL
previous( ) override
;
154 virtual void SAL_CALL
refreshRow( ) override
;
155 virtual sal_Bool SAL_CALL
rowUpdated( ) override
;
156 virtual sal_Bool SAL_CALL
rowInserted( ) override
;
157 virtual sal_Bool SAL_CALL
rowDeleted( ) override
;
158 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getStatement( ) override
;
160 virtual sal_Bool SAL_CALL
wasNull( ) override
;
161 virtual OUString SAL_CALL
getString( sal_Int32 columnIndex
) override
;
162 virtual sal_Bool SAL_CALL
getBoolean( sal_Int32 columnIndex
) override
;
163 virtual sal_Int8 SAL_CALL
getByte( sal_Int32 columnIndex
) override
;
164 virtual sal_Int16 SAL_CALL
getShort( sal_Int32 columnIndex
) override
;
165 virtual sal_Int32 SAL_CALL
getInt( sal_Int32 columnIndex
) override
;
166 virtual sal_Int64 SAL_CALL
getLong( sal_Int32 columnIndex
) override
;
167 virtual float SAL_CALL
getFloat( sal_Int32 columnIndex
) override
;
168 virtual double SAL_CALL
getDouble( sal_Int32 columnIndex
) override
;
169 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getBytes( sal_Int32 columnIndex
) override
;
170 virtual css::util::Date SAL_CALL
getDate( sal_Int32 columnIndex
) override
;
171 virtual css::util::Time SAL_CALL
getTime( sal_Int32 columnIndex
) override
;
172 virtual css::util::DateTime SAL_CALL
getTimestamp( sal_Int32 columnIndex
) override
;
173 virtual css::uno::Reference
< css::io::XInputStream
> SAL_CALL
getBinaryStream( sal_Int32 columnIndex
) override
;
174 virtual css::uno::Reference
< css::io::XInputStream
> SAL_CALL
getCharacterStream( sal_Int32 columnIndex
) override
;
175 virtual css::uno::Any SAL_CALL
getObject( sal_Int32 columnIndex
, const css::uno::Reference
< css::container::XNameAccess
>& typeMap
) override
;
176 virtual css::uno::Reference
< css::sdbc::XRef
> SAL_CALL
getRef( sal_Int32 columnIndex
) override
;
177 virtual css::uno::Reference
< css::sdbc::XBlob
> SAL_CALL
getBlob( sal_Int32 columnIndex
) override
;
178 virtual css::uno::Reference
< css::sdbc::XClob
> SAL_CALL
getClob( sal_Int32 columnIndex
) override
;
179 virtual css::uno::Reference
< css::sdbc::XArray
> SAL_CALL
getArray( sal_Int32 columnIndex
) override
;
180 // XResultSetMetaDataSupplier
181 virtual css::uno::Reference
< css::sdbc::XResultSetMetaData
> SAL_CALL
getMetaData( ) override
;
183 virtual void SAL_CALL
cancel( ) override
;
185 virtual void SAL_CALL
close( ) override
;
187 virtual css::uno::Any SAL_CALL
getWarnings( ) override
;
188 virtual void SAL_CALL
clearWarnings( ) override
;
190 virtual sal_Int32 SAL_CALL
findColumn( const OUString
& columnName
) override
;
192 const std::vector
<sal_Int32
>& getColumnMapping() { return m_aColMapping
; }
194 void setCatalogsMap();
195 void setSchemasMap();
196 void setColumnPrivilegesMap();
197 void setColumnsMap();
199 void setProcedureColumnsMap();
200 void setProceduresMap();
201 void setExportedKeysMap();
202 void setImportedKeysMap();
203 void setPrimaryKeysMap();
204 void setIndexInfoMap();
205 void setTablePrivilegesMap();
206 void setCrossReferenceMap();
207 void setTypeInfoMap(bool _bJetEngine
);
210 inline sal_Int32
ODatabaseMetaDataResultSet::mapColumn (sal_Int32 column
)
212 sal_Int32 map
= column
;
214 if (!m_aColMapping
.empty())
216 // Validate column number
217 map
= m_aColMapping
[column
];
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */