tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / connectivity / source / inc / FDatabaseMetaDataResultSet.hxx
blob28c504ee416bbb358da99dfb2423561bbf549429
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #pragma once
22 #include <sal/config.h>
24 #include <vector>
26 #include <com/sun/star/sdbc/XResultSet.hpp>
27 #include <com/sun/star/sdbc/XRow.hpp>
28 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
29 #include <com/sun/star/sdbc/XCloseable.hpp>
30 #include <com/sun/star/sdbc/XColumnLocate.hpp>
31 #include <com/sun/star/util/XCancellable.hpp>
32 #include <com/sun/star/lang/XInitialization.hpp>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
35 #include <comphelper/proparrhlp.hxx>
36 #include <comphelper/propertycontainer2.hxx>
37 #include <connectivity/FValue.hxx>
38 #include <connectivity/dbtoolsdllapi.hxx>
39 #include <comphelper/compbase.hxx>
41 namespace connectivity
43 class ODatabaseMetaDataResultSetMetaData;
45 typedef ::comphelper::WeakComponentImplHelper< css::sdbc::XResultSet,
46 css::sdbc::XRow,
47 css::sdbc::XResultSetMetaDataSupplier,
48 css::util::XCancellable,
49 css::sdbc::XWarningsSupplier,
50 css::sdbc::XCloseable,
51 css::lang::XInitialization,
52 css::lang::XServiceInfo,
53 css::sdbc::XColumnLocate> ODatabaseMetaDataResultSet_BASE;
55 // typedef ORefVector<ORowSetValue> ORow;
56 // typedef ORefVector<ORow> ORows;
58 class SAL_DLLPUBLIC_RTTI ODatabaseMetaDataResultSet :
59 public ODatabaseMetaDataResultSet_BASE,
60 public ::comphelper::OPropertyContainer2,
61 public ::comphelper::OPropertyArrayUsageHelper<ODatabaseMetaDataResultSet>
64 public:
65 typedef std::vector<ORowSetValueDecoratorRef> ORow;
66 typedef std::vector<ORow> ORows;
68 enum MetaDataResultSetType
70 /// describes a result set as expected by XDatabaseMetaData::getCatalogs
71 eCatalogs = 0,
72 /// describes a result set as expected by XDatabaseMetaData::getSchemas
73 eSchemas = 1,
74 /// describes a result set as expected by XDatabaseMetaData::getColumnPrivileges
75 eColumnPrivileges = 2,
76 /// describes a result set as expected by XDatabaseMetaData::getColumns
77 eColumns = 3,
78 /// describes a result set as expected by XDatabaseMetaData::getTables
79 eTables = 4,
80 /// describes a result set as expected by XDatabaseMetaData::getTableTypes
81 eTableTypes = 5,
82 /// describes a result set as expected by XDatabaseMetaData::getProcedureColumns
83 eProcedureColumns = 6,
84 /// describes a result set as expected by XDatabaseMetaData::getProcedures
85 eProcedures = 7,
86 /// describes a result set as expected by XDatabaseMetaData::getExportedKeys
87 eExportedKeys = 8,
88 /// describes a result set as expected by XDatabaseMetaData::getImportedKeys
89 eImportedKeys = 9,
90 /// describes a result set as expected by XDatabaseMetaData::getPrimaryKeys
91 ePrimaryKeys = 10,
92 /// describes a result set as expected by XDatabaseMetaData::getIndexInfo
93 eIndexInfo = 11,
94 /// describes a result set as expected by XDatabaseMetaData::getTablePrivileges
95 eTablePrivileges = 12,
96 /// describes a result set as expected by XDatabaseMetaData::getCrossReference
97 eCrossReference = 13,
98 /// describes a result set as expected by XDatabaseMetaData::getTypeInfo
99 eTypeInfo = 14,
100 /// describes a result set as expected by XDatabaseMetaData::getBestRowIdentifier
101 eBestRowIdentifier = 15,
102 /// describes a result set as expected by XDatabaseMetaData::getVersionColumns
103 eVersionColumns = 16,
104 /// describes a result set as expected by XDatabaseMetaData::getUDTs
105 eUDTs = 17
108 private:
109 ORowSetValue m_aEmptyValue;
110 css::uno::WeakReferenceHelper m_aStatement;
111 rtl::Reference< ODatabaseMetaDataResultSetMetaData> m_xMetaData;
112 sal_Int32 m_nColPos;
114 sal_Int32 m_nFetchSize;
115 sal_Int32 m_nResultSetType;
116 sal_Int32 m_nFetchDirection;
117 sal_Int32 m_nResultSetConcurrency;
119 void construct();
120 /// @throws css::sdbc::SQLException
121 void checkIndex(std::unique_lock<std::mutex>& rGuard, sal_Int32 columnIndex );
122 void setType(MetaDataResultSetType _eType);
123 css::uno::Reference< css::sdbc::XResultSetMetaData > getMetaData( std::unique_lock<std::mutex>& );
125 protected:
126 ORows m_aRows;
127 ORows::iterator m_aRowsIter;
128 bool m_bBOF;
129 bool m_bEOF;
131 virtual const ORowSetValue& getValue(sal_Int32 columnIndex);
133 // OPropertyArrayUsageHelper
134 OOO_DLLPUBLIC_DBTOOLS virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
135 // OPropertySetHelper
136 OOO_DLLPUBLIC_DBTOOLS virtual ::cppu::IPropertyArrayHelper & getInfoHelper() override;
138 bool next(std::unique_lock<std::mutex>& );
139 bool isBeforeFirst(std::unique_lock<std::mutex>& );
140 bool isAfterLast(std::unique_lock<std::mutex>& );
142 virtual ~ODatabaseMetaDataResultSet() override;
143 public:
145 OOO_DLLPUBLIC_DBTOOLS virtual void SAL_CALL acquire() noexcept override;
146 OOO_DLLPUBLIC_DBTOOLS virtual void SAL_CALL release() noexcept override;
148 /// default construction
149 ODatabaseMetaDataResultSet();
150 /// construction of a pre-defined result set type
151 OOO_DLLPUBLIC_DBTOOLS ODatabaseMetaDataResultSet( MetaDataResultSetType _eType );
153 OOO_DLLPUBLIC_DBTOOLS void setRows(ORows&& _rRows);
155 // XServiceInfo
157 protected:
158 virtual OUString SAL_CALL getImplementationName( ) override;
159 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
160 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
161 // ::comphelper::WeakComponentImplHelper
162 virtual void disposing(std::unique_lock<std::mutex>&) override;
163 // XInterface
164 OOO_DLLPUBLIC_DBTOOLS virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
165 //XTypeProvider
166 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
167 // XPropertySet
168 OOO_DLLPUBLIC_DBTOOLS virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
169 // XResultSet
170 virtual sal_Bool SAL_CALL next( ) override;
171 virtual sal_Bool SAL_CALL isBeforeFirst( ) override;
172 virtual sal_Bool SAL_CALL isAfterLast( ) override;
173 virtual sal_Bool SAL_CALL isFirst( ) override;
174 virtual sal_Bool SAL_CALL isLast( ) override;
175 virtual void SAL_CALL beforeFirst( ) override;
176 virtual void SAL_CALL afterLast( ) override;
177 virtual sal_Bool SAL_CALL first( ) override;
178 virtual sal_Bool SAL_CALL last( ) override;
179 virtual sal_Int32 SAL_CALL getRow( ) override;
180 virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) override;
181 virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) override;
182 virtual sal_Bool SAL_CALL previous( ) override;
183 virtual void SAL_CALL refreshRow( ) override;
184 virtual sal_Bool SAL_CALL rowUpdated( ) override;
185 virtual sal_Bool SAL_CALL rowInserted( ) override;
186 virtual sal_Bool SAL_CALL rowDeleted( ) override;
187 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement( ) override;
188 // XRow
189 virtual sal_Bool SAL_CALL wasNull( ) override;
190 virtual OUString SAL_CALL getString( sal_Int32 columnIndex ) override;
191 virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) override;
192 virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) override;
193 virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) override;
194 virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) override;
195 virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) override;
196 virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) override;
197 virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) override;
198 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) override;
199 virtual css::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) override;
200 virtual css::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) override;
201 virtual css::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) override;
202 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) override;
203 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) override;
204 virtual css::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess >& typeMap ) override;
205 virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) override;
206 virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) override;
207 virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) override;
208 virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) override;
209 // XResultSetMetaDataSupplier
210 virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) override;
211 // XCancellable
212 virtual void SAL_CALL cancel( ) override;
213 // XCloseable
214 virtual void SAL_CALL close( ) override;
215 // XWarningsSupplier
216 virtual css::uno::Any SAL_CALL getWarnings( ) override;
217 virtual void SAL_CALL clearWarnings( ) override;
218 // XColumnLocate
219 virtual sal_Int32 SAL_CALL findColumn( const OUString& columnName ) override;
221 // XInitialization
222 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
224 void setCatalogsMap();
225 void setSchemasMap();
226 void setColumnPrivilegesMap();
227 void setColumnsMap();
228 void setTablesMap();
229 void setTableTypes();
230 void setProcedureColumnsMap();
231 void setProceduresMap();
232 void setExportedKeysMap();
233 void setImportedKeysMap();
234 void setPrimaryKeysMap();
235 void setIndexInfoMap();
236 void setTablePrivilegesMap();
237 void setCrossReferenceMap();
238 void setTypeInfoMap();
239 void setBestRowIdentifierMap();
240 void setVersionColumnsMap();
241 void setUDTsMap();
242 public:
243 // some methods to get already defined ORowSetValues
244 // this increase the reuse of ORowSetValues
245 /// return an empty ORowSetValueDecorator
246 OOO_DLLPUBLIC_DBTOOLS static ORowSetValueDecoratorRef const & getEmptyValue();
247 /// return an ORowSetValueDecorator with 0 as value
248 OOO_DLLPUBLIC_DBTOOLS static ORowSetValueDecoratorRef const & get0Value();
249 /// return an ORowSetValueDecorator with 1 as value
250 OOO_DLLPUBLIC_DBTOOLS static ORowSetValueDecoratorRef const & get1Value();
251 /// return an ORowSetValueDecorator with ColumnSearch::BASIC as value
252 OOO_DLLPUBLIC_DBTOOLS static ORowSetValueDecoratorRef const & getBasicValue();
253 /// return an ORowSetValueDecorator with string SELECT as value
254 OOO_DLLPUBLIC_DBTOOLS static ORowSetValueDecoratorRef const & getSelectValue();
255 /// return an ORowSetValueDecorator with string INSERT as value
256 OOO_DLLPUBLIC_DBTOOLS static ORowSetValueDecoratorRef const & getInsertValue();
257 /// return an ORowSetValueDecorator with string DELETE as value
258 OOO_DLLPUBLIC_DBTOOLS static ORowSetValueDecoratorRef const & getDeleteValue();
259 /// return an ORowSetValueDecorator with string UPDATE as value
260 OOO_DLLPUBLIC_DBTOOLS static ORowSetValueDecoratorRef const & getUpdateValue();
261 /// return an ORowSetValueDecorator with string CREATE as value
262 OOO_DLLPUBLIC_DBTOOLS static ORowSetValueDecoratorRef const & getCreateValue();
263 /// return an ORowSetValueDecorator with string READ as value
264 OOO_DLLPUBLIC_DBTOOLS static ORowSetValueDecoratorRef const & getReadValue();
265 /// return an ORowSetValueDecorator with string ALTER as value
266 OOO_DLLPUBLIC_DBTOOLS static ORowSetValueDecoratorRef const & getAlterValue();
267 /// return an ORowSetValueDecorator with string DROP as value
268 OOO_DLLPUBLIC_DBTOOLS static ORowSetValueDecoratorRef const & getDropValue();
269 /// return an ORowSetValueDecorator with string ' as value
270 OOO_DLLPUBLIC_DBTOOLS static ORowSetValueDecoratorRef const & getQuoteValue();
275 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */