1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _CONNECTIVITY_FDATABASEMETADATARESULTSET_HXX_
30 #define _CONNECTIVITY_FDATABASEMETADATARESULTSET_HXX_
32 #include <com/sun/star/sdbc/XResultSet.hpp>
33 #include <com/sun/star/sdbc/XRow.hpp>
34 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
35 #include <com/sun/star/sdbc/XCloseable.hpp>
36 #include <com/sun/star/sdbc/XColumnLocate.hpp>
37 #include <com/sun/star/util/XCancellable.hpp>
38 #include <com/sun/star/lang/XInitialization.hpp>
39 #include <com/sun/star/lang/XServiceInfo.hpp>
40 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
41 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
42 #include <com/sun/star/sdbc/XRowUpdate.hpp>
43 #include <cppuhelper/compbase9.hxx>
44 #include <comphelper/proparrhlp.hxx>
45 #include "connectivity/CommonTools.hxx"
46 #include <comphelper/propertycontainer.hxx>
47 #include "connectivity/FValue.hxx"
48 #include "connectivity/dbtoolsdllapi.hxx"
49 #include <comphelper/broadcasthelper.hxx>
50 #include <salhelper/simplereferenceobject.hxx>
52 namespace connectivity
54 class ODatabaseMetaDataResultSetMetaData
;
55 typedef ::cppu::WeakComponentImplHelper9
< ::com::sun::star::sdbc::XResultSet
,
56 ::com::sun::star::sdbc::XRow
,
57 ::com::sun::star::sdbc::XResultSetMetaDataSupplier
,
58 ::com::sun::star::util::XCancellable
,
59 ::com::sun::star::sdbc::XWarningsSupplier
,
60 ::com::sun::star::sdbc::XCloseable
,
61 ::com::sun::star::lang::XInitialization
,
62 ::com::sun::star::lang::XServiceInfo
,
63 ::com::sun::star::sdbc::XColumnLocate
> ODatabaseMetaDataResultSet_BASE
;
65 // typedef ORefVector<ORowSetValue> ORow;
66 // typedef ORefVector<ORow> ORows;
68 class OOO_DLLPUBLIC_DBTOOLS ODatabaseMetaDataResultSet
:
69 public comphelper::OBaseMutex
,
70 public ODatabaseMetaDataResultSet_BASE
,
71 public ::comphelper::OPropertyContainer
,
72 public ::comphelper::OPropertyArrayUsageHelper
<ODatabaseMetaDataResultSet
>
76 DECLARE_STL_VECTOR(ORowSetValueDecoratorRef
,ORow
);
77 DECLARE_STL_VECTOR(ORow
, ORows
);
79 enum MetaDataResultSetType
81 /// describes a result set as expected by XDatabaseMetaData::getCatalogs
83 /// describes a result set as expected by XDatabaseMetaData::getSchemas
85 /// describes a result set as expected by XDatabaseMetaData::getColumnPrivileges
86 eColumnPrivileges
= 2,
87 /// describes a result set as expected by XDatabaseMetaData::getColumns
89 /// describes a result set as expected by XDatabaseMetaData::getTables
91 /// describes a result set as expected by XDatabaseMetaData::getTableTypes
93 /// describes a result set as expected by XDatabaseMetaData::getProcedureColumns
94 eProcedureColumns
= 6,
95 /// describes a result set as expected by XDatabaseMetaData::getProcedures
97 /// describes a result set as expected by XDatabaseMetaData::getExportedKeys
99 /// describes a result set as expected by XDatabaseMetaData::getImportedKeys
101 /// describes a result set as expected by XDatabaseMetaData::getPrimaryKeys
103 /// describes a result set as expected by XDatabaseMetaData::getIndexInfo
105 /// describes a result set as expected by XDatabaseMetaData::getTablePrivileges
106 eTablePrivileges
= 12,
107 /// describes a result set as expected by XDatabaseMetaData::getCrossReference
108 eCrossReference
= 13,
109 /// describes a result set as expected by XDatabaseMetaData::getTypeInfo
111 /// describes a result set as expected by XDatabaseMetaData::getBestRowIdentifier
112 eBestRowIdentifier
= 15,
113 /// describes a result set as expected by XDatabaseMetaData::getVersionColumns
118 ORowSetValue m_aEmptyValue
;
119 ::com::sun::star::uno::WeakReferenceHelper m_aStatement
;
120 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSetMetaData
> m_xMetaData
;
123 sal_Int32 m_nFetchSize
;
124 sal_Int32 m_nResultSetType
;
125 sal_Int32 m_nFetchDirection
;
126 sal_Int32 m_nResultSetConcurrency
;
129 void checkIndex(sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
);
130 void setType(MetaDataResultSetType _eType
);
134 ORows::iterator m_aRowsIter
;
138 virtual const ORowSetValue
& getValue(sal_Int32 columnIndex
);
140 // OPropertyArrayUsageHelper
141 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const;
142 // OPropertySetHelper
143 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper();
145 virtual ~ODatabaseMetaDataResultSet();
148 virtual void SAL_CALL
acquire() throw();
149 virtual void SAL_CALL
release() throw();
151 /// default construction
152 ODatabaseMetaDataResultSet();
153 /// construction of a pre-defined result set type
154 ODatabaseMetaDataResultSet( MetaDataResultSetType _eType
);
156 void setRows(const ORows
& _rRows
);
160 static ::rtl::OUString
getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException
);
161 static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException
);
164 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw (::com::sun::star::uno::RuntimeException
);
165 virtual ::sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
) throw (::com::sun::star::uno::RuntimeException
);
166 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException
);
167 // ::cppu::OComponentHelper
168 virtual void SAL_CALL
disposing(void);
170 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
);
172 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( ) throw(::com::sun::star::uno::RuntimeException
);
174 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
);
176 virtual sal_Bool SAL_CALL
next( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
177 virtual sal_Bool SAL_CALL
isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
178 virtual sal_Bool SAL_CALL
isAfterLast( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
179 virtual sal_Bool SAL_CALL
isFirst( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
180 virtual sal_Bool SAL_CALL
isLast( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
181 virtual void SAL_CALL
beforeFirst( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
182 virtual void SAL_CALL
afterLast( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
183 virtual sal_Bool SAL_CALL
first( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
184 virtual sal_Bool SAL_CALL
last( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
185 virtual sal_Int32 SAL_CALL
getRow( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
186 virtual sal_Bool SAL_CALL
absolute( sal_Int32 row
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
187 virtual sal_Bool SAL_CALL
relative( sal_Int32 rows
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
188 virtual sal_Bool SAL_CALL
previous( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
189 virtual void SAL_CALL
refreshRow( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
190 virtual sal_Bool SAL_CALL
rowUpdated( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
191 virtual sal_Bool SAL_CALL
rowInserted( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
192 virtual sal_Bool SAL_CALL
rowDeleted( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
193 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
getStatement( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
195 virtual sal_Bool SAL_CALL
wasNull( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
196 virtual ::rtl::OUString SAL_CALL
getString( sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
197 virtual sal_Bool SAL_CALL
getBoolean( sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
198 virtual sal_Int8 SAL_CALL
getByte( sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
199 virtual sal_Int16 SAL_CALL
getShort( sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
200 virtual sal_Int32 SAL_CALL
getInt( sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
201 virtual sal_Int64 SAL_CALL
getLong( sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
202 virtual float SAL_CALL
getFloat( sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
203 virtual double SAL_CALL
getDouble( sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
204 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getBytes( sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
205 virtual ::com::sun::star::util::Date SAL_CALL
getDate( sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
206 virtual ::com::sun::star::util::Time SAL_CALL
getTime( sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
207 virtual ::com::sun::star::util::DateTime SAL_CALL
getTimestamp( sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
208 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::io::XInputStream
> SAL_CALL
getBinaryStream( sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
209 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::io::XInputStream
> SAL_CALL
getCharacterStream( sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
210 virtual ::com::sun::star::uno::Any SAL_CALL
getObject( sal_Int32 columnIndex
, const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>& typeMap
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
211 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRef
> SAL_CALL
getRef( sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
212 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XBlob
> SAL_CALL
getBlob( sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
213 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XClob
> SAL_CALL
getClob( sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
214 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XArray
> SAL_CALL
getArray( sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
215 // XResultSetMetaDataSupplier
216 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSetMetaData
> SAL_CALL
getMetaData( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
218 virtual void SAL_CALL
cancel( ) throw(::com::sun::star::uno::RuntimeException
);
220 virtual void SAL_CALL
close( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
222 virtual ::com::sun::star::uno::Any SAL_CALL
getWarnings( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
223 virtual void SAL_CALL
clearWarnings( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
225 virtual sal_Int32 SAL_CALL
findColumn( const ::rtl::OUString
& columnName
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
228 virtual void SAL_CALL
initialize( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aArguments
) throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
230 void setCatalogsMap();
231 void setSchemasMap();
232 void setColumnPrivilegesMap();
233 void setColumnsMap();
235 void setTableTypes();
236 void setProcedureColumnsMap();
237 void setProceduresMap();
238 void setExportedKeysMap();
239 void setImportedKeysMap();
240 void setPrimaryKeysMap();
241 void setIndexInfoMap();
242 void setTablePrivilegesMap();
243 void setCrossReferenceMap();
244 void setTypeInfoMap();
245 void setBestRowIdentifierMap();
246 void setVersionColumnsMap();
248 // some methods to get already defined ORowSetValues
249 // this increase the reuse of ORowSetValues
250 /// return an empty ORowSetValueDecorator
251 static ORowSetValueDecoratorRef
getEmptyValue();
252 /// return an ORowSetValueDecorator with 0 as value
253 static ORowSetValueDecoratorRef
get0Value();
254 /// return an ORowSetValueDecorator with 1 as value
255 static ORowSetValueDecoratorRef
get1Value();
256 /// return an ORowSetValueDecorator with ColumnSearch::BASIC as value
257 static ORowSetValueDecoratorRef
getBasicValue();
258 /// return an ORowSetValueDecorator with string SELECT as value
259 static ORowSetValueDecoratorRef
getSelectValue();
260 /// return an ORowSetValueDecorator with string INSERT as value
261 static ORowSetValueDecoratorRef
getInsertValue();
262 /// return an ORowSetValueDecorator with string DELETE as value
263 static ORowSetValueDecoratorRef
getDeleteValue();
264 /// return an ORowSetValueDecorator with string UPDATE as value
265 static ORowSetValueDecoratorRef
getUpdateValue();
266 /// return an ORowSetValueDecorator with string CREATE as value
267 static ORowSetValueDecoratorRef
getCreateValue();
268 /// return an ORowSetValueDecorator with string READ as value
269 static ORowSetValueDecoratorRef
getReadValue();
270 /// return an ORowSetValueDecorator with string ALTER as value
271 static ORowSetValueDecoratorRef
getAlterValue();
272 /// return an ORowSetValueDecorator with string DROP as value
273 static ORowSetValueDecoratorRef
getDropValue();
274 /// return an ORowSetValueDecorator with string ' as value
275 static ORowSetValueDecoratorRef
getQuoteValue();
279 #endif // _CONNECTIVITY_FDATABASEMETADATARESULTSET_HXX_
281 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */