1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _CONNECTIVITY_ADO_ADATABASEMETADATARESULTSETMETADATA_HXX_
25 #define _CONNECTIVITY_ADO_ADATABASEMETADATARESULTSETMETADATA_HXX_
26 
27 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
28 #include <cppuhelper/implbase1.hxx>
29 #ifndef _VECTOR_
30 #include <vector>
31 #endif
32 #include "ado/Awrapado.hxx"
33 #include "ado/ADatabaseMetaDataResultSet.hxx"
34 #include "OColumn.hxx"
35 
36 namespace connectivity
37 {
38 	namespace ado
39 	{
40 		//**************************************************************
41 		//************ Class: ResultSetMetaData
42 		//**************************************************************
43                 typedef ::cppu::WeakImplHelper1<        ::com::sun::star::sdbc::XResultSetMetaData>   ODatabaseMetaResultSetMetaData_BASE;
44 
45 		class ODatabaseMetaDataResultSetMetaData :	public 	ODatabaseMetaResultSetMetaData_BASE
46 		{
47 			friend class ODatabaseMetaDataResultSet;
48 
49 			const ::std::vector<sal_Int32> &m_vMapping; // when not every column is needed
50 			::std::map<sal_Int32,connectivity::OColumn>	m_mColumns;
51 			::std::map<sal_Int32,connectivity::OColumn>::const_iterator m_mColumnsIter;
52 
53 			ADORecordset*	m_pRecordSet;
54 			sal_Int32		m_nColCount;
55 
56 		private:
57 			ODatabaseMetaDataResultSetMetaData( const ODatabaseMetaDataResultSetMetaData& );			// never implemented
58 			ODatabaseMetaDataResultSetMetaData& operator=( const ODatabaseMetaDataResultSetMetaData& );	// never implemented
59 
60 		protected:
61 			void setColumnPrivilegesMap();
62 			void setColumnsMap();
63 			void setTablesMap();
64 			void setProcedureColumnsMap();
65 			void setPrimaryKeysMap();
66 			void setIndexInfoMap();
67 			void setTablePrivilegesMap();
68 			void setCrossReferenceMap();
69 			void setTypeInfoMap();
70 			void setProceduresMap();
71 		public:
72 			// ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
ODatabaseMetaDataResultSetMetaData(ADORecordset * _pRecordSet,ODatabaseMetaDataResultSet * _pRes)73 			ODatabaseMetaDataResultSetMetaData( ADORecordset* _pRecordSet ,ODatabaseMetaDataResultSet* _pRes)
74 					:	m_pRecordSet(_pRecordSet),m_vMapping(_pRes->getColumnMapping()),
75 						m_nColCount(m_vMapping.size()-1)
76 			{
77 				if(m_pRecordSet)
78 					m_pRecordSet->AddRef();
79 			}
80 			~ODatabaseMetaDataResultSetMetaData();
81 
82 			/// Avoid ambigous cast error from the compiler.
operator ::com::sun::star::uno::Reference<::com::sun::star::sdbc::XResultSetMetaData>()83             inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw()
84 			{ return this; }
85 
86 			virtual sal_Int32 SAL_CALL getColumnCount(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
87 			virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
88 			virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
89 			virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
90 			virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
91 			virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
92 			virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
93 			virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
94 			virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
95 			virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
96 			virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
97 			virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
98 			virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
99 			virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
100 			virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
101 			virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
102 			virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
103 			virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
104 			virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
105 			virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
106 			virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
107 		};
108 	}
109 }
110 #endif // _CONNECTIVITY_ADO_ADATABASEMETARESULTSETMETADATA_HXX_
111 
112