1*9b5730f6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9b5730f6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9b5730f6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9b5730f6SAndrew Rist  * distributed with this work for additional information
6*9b5730f6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9b5730f6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9b5730f6SAndrew Rist  * "License"); you may not use this file except in compliance
9*9b5730f6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9b5730f6SAndrew Rist  *
11*9b5730f6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9b5730f6SAndrew Rist  *
13*9b5730f6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9b5730f6SAndrew Rist  * software distributed under the License is distributed on an
15*9b5730f6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9b5730f6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9b5730f6SAndrew Rist  * specific language governing permissions and limitations
18*9b5730f6SAndrew Rist  * under the License.
19*9b5730f6SAndrew Rist  *
20*9b5730f6SAndrew Rist  *************************************************************/
21*9b5730f6SAndrew Rist 
22*9b5730f6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
26cdf0e10cSrcweir #include "ado/ADatabaseMetaData.hxx"
27cdf0e10cSrcweir #include "ado/ADatabaseMetaDataResultSetMetaData.hxx"
28cdf0e10cSrcweir #include "ado/Awrapado.hxx"
29cdf0e10cSrcweir #include "ado/AGroup.hxx"
30cdf0e10cSrcweir #include "ado/adoimp.hxx"
31cdf0e10cSrcweir #include "ado/AIndex.hxx"
32cdf0e10cSrcweir #include "ado/AKey.hxx"
33cdf0e10cSrcweir #include "ado/ATable.hxx"
34cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp>
35cdf0e10cSrcweir #include <com/sun/star/sdbc/ProcedureResult.hpp>
36cdf0e10cSrcweir #include <com/sun/star/sdbc/ColumnValue.hpp>
37cdf0e10cSrcweir #ifdef DELETE
38cdf0e10cSrcweir #undef DELETE
39cdf0e10cSrcweir #endif
40cdf0e10cSrcweir #include <com/sun/star/sdbcx/Privilege.hpp>
41cdf0e10cSrcweir #include <com/sun/star/sdbcx/PrivilegeObject.hpp>
42cdf0e10cSrcweir #include <com/sun/star/sdbc/KeyRule.hpp>
43cdf0e10cSrcweir #include <com/sun/star/sdbcx/KeyType.hpp>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir using namespace connectivity::ado;
46cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
47cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx;
48cdf0e10cSrcweir using namespace ::com::sun::star::uno;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir // -------------------------------------------------------------------------
fillLiterals()51cdf0e10cSrcweir void ODatabaseMetaData::fillLiterals()
52cdf0e10cSrcweir {
53cdf0e10cSrcweir 	ADORecordset *pRecordset = NULL;
54cdf0e10cSrcweir 	OLEVariant  vtEmpty;
55cdf0e10cSrcweir 	vtEmpty.setNoArg();
56cdf0e10cSrcweir 	m_pADOConnection->OpenSchema(adSchemaDBInfoLiterals,vtEmpty,vtEmpty,&pRecordset);
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 	ADOS::ThrowException(*m_pADOConnection,*this);
59cdf0e10cSrcweir 
60cdf0e10cSrcweir 	OSL_ENSURE(pRecordset,"fillLiterals: no resultset!");
61cdf0e10cSrcweir 	if ( pRecordset )
62cdf0e10cSrcweir 	{
63cdf0e10cSrcweir 		WpADORecordset aRecordset(pRecordset);
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 		aRecordset.MoveFirst();
66cdf0e10cSrcweir 		OLEVariant  aValue;
67cdf0e10cSrcweir 		LiteralInfo aInfo;
68cdf0e10cSrcweir 		while(!aRecordset.IsAtEOF())
69cdf0e10cSrcweir 		{
70cdf0e10cSrcweir 			WpOLEAppendCollection<ADOFields, ADOField, WpADOField>	aFields(aRecordset.GetFields());
71cdf0e10cSrcweir 			WpADOField aField(aFields.GetItem(1));
72cdf0e10cSrcweir 			aInfo.pwszLiteralValue = aField.get_Value();
73cdf0e10cSrcweir 			aField = aFields.GetItem(5);
74cdf0e10cSrcweir 			aInfo.fSupported = aField.get_Value();
75cdf0e10cSrcweir 			aField = aFields.GetItem(6);
76cdf0e10cSrcweir 			aInfo.cchMaxLen = aField.get_Value().getUInt32();
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 			aField = aFields.GetItem(4);
79cdf0e10cSrcweir 			sal_uInt32 nId = aField.get_Value().getUInt32();
80cdf0e10cSrcweir 			m_aLiteralInfo[nId] = aInfo;
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 			aRecordset.MoveNext();
83cdf0e10cSrcweir 		}
84cdf0e10cSrcweir 		aRecordset.Close();
85cdf0e10cSrcweir 	}
86cdf0e10cSrcweir }
87cdf0e10cSrcweir // -------------------------------------------------------------------------
getMaxSize(sal_uInt32 _nId)88cdf0e10cSrcweir sal_Int32 ODatabaseMetaData::getMaxSize(sal_uInt32 _nId)
89cdf0e10cSrcweir {
90cdf0e10cSrcweir 	if(!m_aLiteralInfo.size())
91cdf0e10cSrcweir 		fillLiterals();
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 	sal_Int32 nSize = 0;
94cdf0e10cSrcweir 	::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId);
95cdf0e10cSrcweir 	if(aIter != m_aLiteralInfo.end() && (*aIter).second.fSupported)
96cdf0e10cSrcweir 		nSize = ((*aIter).second.cchMaxLen == (-1)) ? 0 : (*aIter).second.cchMaxLen;
97cdf0e10cSrcweir 	return nSize;
98cdf0e10cSrcweir }
99cdf0e10cSrcweir // -------------------------------------------------------------------------
isCapable(sal_uInt32 _nId)100cdf0e10cSrcweir sal_Bool ODatabaseMetaData::isCapable(sal_uInt32 _nId)
101cdf0e10cSrcweir {
102cdf0e10cSrcweir 	if(!m_aLiteralInfo.size())
103cdf0e10cSrcweir 		fillLiterals();
104cdf0e10cSrcweir 	sal_Bool bSupported = sal_False;
105cdf0e10cSrcweir 	::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId);
106cdf0e10cSrcweir 	if(aIter != m_aLiteralInfo.end())
107cdf0e10cSrcweir 		bSupported = (*aIter).second.fSupported;
108cdf0e10cSrcweir 	return bSupported;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir // -------------------------------------------------------------------------
getLiteral(sal_uInt32 _nId)112cdf0e10cSrcweir ::rtl::OUString ODatabaseMetaData::getLiteral(sal_uInt32 _nId)
113cdf0e10cSrcweir {
114cdf0e10cSrcweir 	if(!m_aLiteralInfo.size())
115cdf0e10cSrcweir 		fillLiterals();
116cdf0e10cSrcweir 	::rtl::OUString sStr;
117cdf0e10cSrcweir 	::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId);
118cdf0e10cSrcweir 	if(aIter != m_aLiteralInfo.end() && (*aIter).second.fSupported)
119cdf0e10cSrcweir 		sStr = (*aIter).second.pwszLiteralValue;
120cdf0e10cSrcweir 	return sStr;
121cdf0e10cSrcweir }
122cdf0e10cSrcweir // -----------------------------------------------------------------------------
123cdf0e10cSrcweir // -------------------------------------------------------------------------
setColumnPrivilegesMap()124cdf0e10cSrcweir void ODatabaseMetaDataResultSetMetaData::setColumnPrivilegesMap()
125cdf0e10cSrcweir {
126cdf0e10cSrcweir 	m_mColumns[8] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("IS_GRANTABLE"),
127cdf0e10cSrcweir 		ColumnValue::NULLABLE,
128cdf0e10cSrcweir 		3,3,0,
129cdf0e10cSrcweir 		DataType::VARCHAR);
130cdf0e10cSrcweir }
131cdf0e10cSrcweir // -------------------------------------------------------------------------
setColumnsMap()132cdf0e10cSrcweir void ODatabaseMetaDataResultSetMetaData::setColumnsMap()
133cdf0e10cSrcweir {
134cdf0e10cSrcweir 	m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("TYPE_NAME"),
135cdf0e10cSrcweir 		ColumnValue::NO_NULLS,
136cdf0e10cSrcweir 		0,0,0,
137cdf0e10cSrcweir 		DataType::VARCHAR);
138cdf0e10cSrcweir 	m_mColumns[11] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"),
139cdf0e10cSrcweir 		ColumnValue::NO_NULLS,
140cdf0e10cSrcweir 		1,1,0,
141cdf0e10cSrcweir 		DataType::INTEGER);
142cdf0e10cSrcweir 	m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"),
143cdf0e10cSrcweir 		ColumnValue::NULLABLE,
144cdf0e10cSrcweir 		0,0,0,
145cdf0e10cSrcweir 		DataType::VARCHAR);
146cdf0e10cSrcweir 	m_mColumns[13] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("COLUMN_DEF"),
147cdf0e10cSrcweir 		ColumnValue::NULLABLE,
148cdf0e10cSrcweir 		0,0,0,
149cdf0e10cSrcweir 		DataType::VARCHAR);
150cdf0e10cSrcweir 	m_mColumns[14] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATA_TYPE"),
151cdf0e10cSrcweir 		ColumnValue::NO_NULLS,
152cdf0e10cSrcweir 		1,1,0,
153cdf0e10cSrcweir 		DataType::INTEGER);
154cdf0e10cSrcweir 	m_mColumns[15] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATETIME_SUB"),
155cdf0e10cSrcweir 		ColumnValue::NO_NULLS,
156cdf0e10cSrcweir 		1,1,0,
157cdf0e10cSrcweir 		DataType::INTEGER);
158cdf0e10cSrcweir 	m_mColumns[16] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("CHAR_OCTET_LENGTH"),
159cdf0e10cSrcweir 		ColumnValue::NO_NULLS,
160cdf0e10cSrcweir 		1,1,0,
161cdf0e10cSrcweir 		DataType::INTEGER);
162cdf0e10cSrcweir }
163cdf0e10cSrcweir // -------------------------------------------------------------------------
setTablesMap()164cdf0e10cSrcweir void ODatabaseMetaDataResultSetMetaData::setTablesMap()
165cdf0e10cSrcweir {
166cdf0e10cSrcweir 	m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"),
167cdf0e10cSrcweir 		ColumnValue::NULLABLE,
168cdf0e10cSrcweir 		0,0,0,
169cdf0e10cSrcweir 		DataType::VARCHAR);
170cdf0e10cSrcweir }
171cdf0e10cSrcweir // -------------------------------------------------------------------------
setProcedureColumnsMap()172cdf0e10cSrcweir void ODatabaseMetaDataResultSetMetaData::setProcedureColumnsMap()
173cdf0e10cSrcweir {
174cdf0e10cSrcweir 	m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"),
175cdf0e10cSrcweir 		ColumnValue::NO_NULLS,
176cdf0e10cSrcweir 		1,1,0,
177cdf0e10cSrcweir 		DataType::INTEGER);
178cdf0e10cSrcweir }
179cdf0e10cSrcweir // -------------------------------------------------------------------------
setPrimaryKeysMap()180cdf0e10cSrcweir void ODatabaseMetaDataResultSetMetaData::setPrimaryKeysMap()
181cdf0e10cSrcweir {
182cdf0e10cSrcweir 	m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("KEY_SEQ"),
183cdf0e10cSrcweir 		ColumnValue::NO_NULLS,
184cdf0e10cSrcweir 		1,1,0,
185cdf0e10cSrcweir 		DataType::INTEGER);
186cdf0e10cSrcweir 	m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PK_NAME"),
187cdf0e10cSrcweir 		ColumnValue::NULLABLE,
188cdf0e10cSrcweir 		0,0,0,
189cdf0e10cSrcweir 		DataType::VARCHAR);
190cdf0e10cSrcweir }
191cdf0e10cSrcweir // -------------------------------------------------------------------------
setIndexInfoMap()192cdf0e10cSrcweir void ODatabaseMetaDataResultSetMetaData::setIndexInfoMap()
193cdf0e10cSrcweir {
194cdf0e10cSrcweir 	m_mColumns[4] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NON_UNIQUE"),
195cdf0e10cSrcweir 		ColumnValue::NO_NULLS,
196cdf0e10cSrcweir 		1,1,0,
197cdf0e10cSrcweir 		DataType::BIT);
198cdf0e10cSrcweir 	m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("INDEX_QUALIFIER"),
199cdf0e10cSrcweir 		ColumnValue::NULLABLE,
200cdf0e10cSrcweir 		0,0,0,
201cdf0e10cSrcweir 		DataType::VARCHAR);
202cdf0e10cSrcweir 	m_mColumns[10] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("ASC_OR_DESC"),
203cdf0e10cSrcweir 		ColumnValue::NULLABLE,
204cdf0e10cSrcweir 		0,0,0,
205cdf0e10cSrcweir 		DataType::VARCHAR);
206cdf0e10cSrcweir }
207cdf0e10cSrcweir // -------------------------------------------------------------------------
setTablePrivilegesMap()208cdf0e10cSrcweir void ODatabaseMetaDataResultSetMetaData::setTablePrivilegesMap()
209cdf0e10cSrcweir {
210cdf0e10cSrcweir 	m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PRIVILEGE"),
211cdf0e10cSrcweir 		ColumnValue::NULLABLE,
212cdf0e10cSrcweir 		0,0,0,
213cdf0e10cSrcweir 		DataType::VARCHAR);
214cdf0e10cSrcweir 	m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("IS_GRANTABLE"),
215cdf0e10cSrcweir 		ColumnValue::NULLABLE,
216cdf0e10cSrcweir 		0,0,0,
217cdf0e10cSrcweir 		DataType::VARCHAR);
218cdf0e10cSrcweir }
219cdf0e10cSrcweir // -------------------------------------------------------------------------
setCrossReferenceMap()220cdf0e10cSrcweir void ODatabaseMetaDataResultSetMetaData::setCrossReferenceMap()
221cdf0e10cSrcweir {
222cdf0e10cSrcweir 	m_mColumns[9] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("KEY_SEQ"),
223cdf0e10cSrcweir 		ColumnValue::NO_NULLS,
224cdf0e10cSrcweir 		1,1,0,
225cdf0e10cSrcweir 		DataType::INTEGER);
226cdf0e10cSrcweir }
227cdf0e10cSrcweir // -------------------------------------------------------------------------
setTypeInfoMap()228cdf0e10cSrcweir void ODatabaseMetaDataResultSetMetaData::setTypeInfoMap()
229cdf0e10cSrcweir {
230cdf0e10cSrcweir 	m_mColumns[3] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PRECISION"),
231cdf0e10cSrcweir 		ColumnValue::NO_NULLS,
232cdf0e10cSrcweir 		1,1,0,
233cdf0e10cSrcweir 		DataType::INTEGER);
234cdf0e10cSrcweir 	m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"),
235cdf0e10cSrcweir 		ColumnValue::NO_NULLS,
236cdf0e10cSrcweir 		1,1,0,
237cdf0e10cSrcweir 		DataType::INTEGER);
238cdf0e10cSrcweir 	m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("AUTO_INCREMENT"),
239cdf0e10cSrcweir 		ColumnValue::NO_NULLS,
240cdf0e10cSrcweir 		1,1,0,
241cdf0e10cSrcweir 		DataType::BIT);
242cdf0e10cSrcweir 	m_mColumns[16] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATA_TYPE"),
243cdf0e10cSrcweir 		ColumnValue::NO_NULLS,
244cdf0e10cSrcweir 		1,1,0,
245cdf0e10cSrcweir 		DataType::INTEGER);
246cdf0e10cSrcweir 	m_mColumns[17] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATETIME_SUB"),
247cdf0e10cSrcweir 		ColumnValue::NO_NULLS,
248cdf0e10cSrcweir 		1,1,0,
249cdf0e10cSrcweir 		DataType::INTEGER);
250cdf0e10cSrcweir 	m_mColumns[18] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NUM_PREC_RADIX"),
251cdf0e10cSrcweir 		ColumnValue::NO_NULLS,
252cdf0e10cSrcweir 		1,1,0,
253cdf0e10cSrcweir 		DataType::INTEGER);
254cdf0e10cSrcweir }
255cdf0e10cSrcweir // -------------------------------------------------------------------------
setProceduresMap()256cdf0e10cSrcweir void ODatabaseMetaDataResultSetMetaData::setProceduresMap()
257cdf0e10cSrcweir {
258cdf0e10cSrcweir 	m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"),
259cdf0e10cSrcweir 		ColumnValue::NULLABLE,
260cdf0e10cSrcweir 		0,0,0,
261cdf0e10cSrcweir 		DataType::VARCHAR);
262cdf0e10cSrcweir }
263cdf0e10cSrcweir // -------------------------------------------------------------------------
isSearchable(sal_Int32 column)264cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException)
265cdf0e10cSrcweir {
266cdf0e10cSrcweir 	if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
267cdf0e10cSrcweir 		return (*m_mColumnsIter).second.isSearchable();
268cdf0e10cSrcweir 	return sal_True;
269cdf0e10cSrcweir }
270cdf0e10cSrcweir // -------------------------------------------------------------------------
isAutoIncrement(sal_Int32 column)271cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException)
272cdf0e10cSrcweir {
273cdf0e10cSrcweir 	if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
274cdf0e10cSrcweir 		return (*m_mColumnsIter).second.isAutoIncrement();
275cdf0e10cSrcweir 	return sal_False;
276cdf0e10cSrcweir }
277cdf0e10cSrcweir // -------------------------------------------------------------------------
getColumnServiceName(sal_Int32 column)278cdf0e10cSrcweir ::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(SQLException, RuntimeException)
279cdf0e10cSrcweir {
280cdf0e10cSrcweir 	if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
281cdf0e10cSrcweir 		return (*m_mColumnsIter).second.getColumnServiceName();
282cdf0e10cSrcweir 	return ::rtl::OUString();
283cdf0e10cSrcweir }
284cdf0e10cSrcweir // -------------------------------------------------------------------------
getTableName(sal_Int32 column)285cdf0e10cSrcweir ::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException)
286cdf0e10cSrcweir {
287cdf0e10cSrcweir 	if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
288cdf0e10cSrcweir 		return (*m_mColumnsIter).second.getTableName();
289cdf0e10cSrcweir 	return ::rtl::OUString();
290cdf0e10cSrcweir }
291cdf0e10cSrcweir // -------------------------------------------------------------------------
getCatalogName(sal_Int32 column)292cdf0e10cSrcweir ::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getCatalogName( sal_Int32 column ) throw(SQLException, RuntimeException)
293cdf0e10cSrcweir {
294cdf0e10cSrcweir 	if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
295cdf0e10cSrcweir 		return (*m_mColumnsIter).second.getCatalogName();
296cdf0e10cSrcweir 	return ::rtl::OUString();
297cdf0e10cSrcweir }
298cdf0e10cSrcweir // -------------------------------------------------------------------------
getColumnTypeName(sal_Int32 column)299cdf0e10cSrcweir ::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException)
300cdf0e10cSrcweir {
301cdf0e10cSrcweir 	if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
302cdf0e10cSrcweir 		return (*m_mColumnsIter).second.getColumnTypeName();
303cdf0e10cSrcweir 	return ::rtl::OUString();
304cdf0e10cSrcweir }
305cdf0e10cSrcweir // -------------------------------------------------------------------------
306cdf0e10cSrcweir 
isCaseSensitive(sal_Int32 column)307cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException)
308cdf0e10cSrcweir {
309cdf0e10cSrcweir 	if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
310cdf0e10cSrcweir 		return (*m_mColumnsIter).second.isCaseSensitive();
311cdf0e10cSrcweir 	return sal_True;
312cdf0e10cSrcweir }
313cdf0e10cSrcweir // -------------------------------------------------------------------------
314cdf0e10cSrcweir 
getSchemaName(sal_Int32 column)315cdf0e10cSrcweir ::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getSchemaName( sal_Int32 column ) throw(SQLException, RuntimeException)
316cdf0e10cSrcweir {
317cdf0e10cSrcweir 	if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
318cdf0e10cSrcweir 		return (*m_mColumnsIter).second.getSchemaName();
319cdf0e10cSrcweir 	return ::rtl::OUString();
320cdf0e10cSrcweir }
321cdf0e10cSrcweir // -----------------------------------------------------------------------------
322cdf0e10cSrcweir // -------------------------------------------------------------------------
MapObjectType(sal_Int32 _ObjType)323cdf0e10cSrcweir ObjectTypeEnum OAdoGroup::MapObjectType(sal_Int32 _ObjType)
324cdf0e10cSrcweir {
325cdf0e10cSrcweir 	ObjectTypeEnum eNumType= adPermObjTable;
326cdf0e10cSrcweir 	switch(_ObjType)
327cdf0e10cSrcweir 	{
328cdf0e10cSrcweir         case PrivilegeObject::TABLE:
329cdf0e10cSrcweir 			break;
330cdf0e10cSrcweir         case PrivilegeObject::VIEW:
331cdf0e10cSrcweir 			eNumType = adPermObjView;
332cdf0e10cSrcweir 			break;
333cdf0e10cSrcweir         case PrivilegeObject::COLUMN:
334cdf0e10cSrcweir 			eNumType = adPermObjColumn;
335cdf0e10cSrcweir 			break;
336cdf0e10cSrcweir 	}
337cdf0e10cSrcweir 	return eNumType;
338cdf0e10cSrcweir }
339cdf0e10cSrcweir // -------------------------------------------------------------------------
MapRight(RightsEnum _eNum)340cdf0e10cSrcweir sal_Int32 OAdoGroup::MapRight(RightsEnum _eNum)
341cdf0e10cSrcweir {
342cdf0e10cSrcweir 	sal_Int32 nRight = 0;
343cdf0e10cSrcweir 	if(_eNum & adRightRead)
344cdf0e10cSrcweir                 nRight |= Privilege::SELECT;
345cdf0e10cSrcweir 	if(_eNum & adRightInsert)
346cdf0e10cSrcweir                 nRight |= Privilege::INSERT;
347cdf0e10cSrcweir 	if(_eNum & adRightUpdate)
348cdf0e10cSrcweir                 nRight |= Privilege::UPDATE;
349cdf0e10cSrcweir 	if(_eNum & adRightDelete)
350cdf0e10cSrcweir                 nRight |= Privilege::DELETE;
351cdf0e10cSrcweir 	if(_eNum & adRightReadDesign)
352cdf0e10cSrcweir                 nRight |= Privilege::READ;
353cdf0e10cSrcweir 	if(_eNum & adRightCreate)
354cdf0e10cSrcweir                 nRight |= Privilege::CREATE;
355cdf0e10cSrcweir 	if(_eNum & adRightWriteDesign)
356cdf0e10cSrcweir                 nRight |= Privilege::ALTER;
357cdf0e10cSrcweir 	if(_eNum & adRightReference)
358cdf0e10cSrcweir                 nRight |= Privilege::REFERENCE;
359cdf0e10cSrcweir 	if(_eNum & adRightDrop)
360cdf0e10cSrcweir                 nRight |= Privilege::DROP;
361cdf0e10cSrcweir 
362cdf0e10cSrcweir 	return nRight;
363cdf0e10cSrcweir }
364cdf0e10cSrcweir // -------------------------------------------------------------------------
Map2Right(sal_Int32 _eNum)365cdf0e10cSrcweir RightsEnum OAdoGroup::Map2Right(sal_Int32 _eNum)
366cdf0e10cSrcweir {
367cdf0e10cSrcweir 	sal_Int32 nRight = adRightNone;
368cdf0e10cSrcweir         if(_eNum & Privilege::SELECT)
369cdf0e10cSrcweir 		nRight |= adRightRead;
370cdf0e10cSrcweir 
371cdf0e10cSrcweir         if(_eNum & Privilege::INSERT)
372cdf0e10cSrcweir 		nRight |= adRightInsert;
373cdf0e10cSrcweir 
374cdf0e10cSrcweir         if(_eNum & Privilege::UPDATE)
375cdf0e10cSrcweir 		nRight |= adRightUpdate;
376cdf0e10cSrcweir 
377cdf0e10cSrcweir         if(_eNum & Privilege::DELETE)
378cdf0e10cSrcweir 		nRight |= adRightDelete;
379cdf0e10cSrcweir 
380cdf0e10cSrcweir         if(_eNum & Privilege::READ)
381cdf0e10cSrcweir 		nRight |= adRightReadDesign;
382cdf0e10cSrcweir 
383cdf0e10cSrcweir         if(_eNum & Privilege::CREATE)
384cdf0e10cSrcweir 		nRight |= adRightCreate;
385cdf0e10cSrcweir 
386cdf0e10cSrcweir         if(_eNum & Privilege::ALTER)
387cdf0e10cSrcweir 		nRight |= adRightWriteDesign;
388cdf0e10cSrcweir 
389cdf0e10cSrcweir         if(_eNum & Privilege::REFERENCE)
390cdf0e10cSrcweir 		nRight |= adRightReference;
391cdf0e10cSrcweir 
392cdf0e10cSrcweir         if(_eNum & Privilege::DROP)
393cdf0e10cSrcweir 		nRight |= adRightDrop;
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 	return (RightsEnum)nRight;
396cdf0e10cSrcweir }
397cdf0e10cSrcweir // -------------------------------------------------------------------------
Create()398cdf0e10cSrcweir void WpADOIndex::Create()
399cdf0e10cSrcweir {
400cdf0e10cSrcweir 	HRESULT         hr = -1;
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 	_ADOIndex* pIndex = NULL;
403cdf0e10cSrcweir 	hr = CoCreateInstance(ADOS::CLSID_ADOINDEX_25,
404cdf0e10cSrcweir 						  NULL,
405cdf0e10cSrcweir 						  CLSCTX_INPROC_SERVER,
406cdf0e10cSrcweir 						  ADOS::IID_ADOINDEX_25,
407cdf0e10cSrcweir 						  (void**)&pIndex );
408cdf0e10cSrcweir 
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 	if( !FAILED( hr ) )
411cdf0e10cSrcweir 	{
412cdf0e10cSrcweir 		operator=( pIndex );
413cdf0e10cSrcweir 		pIndex->Release();
414cdf0e10cSrcweir 	}
415cdf0e10cSrcweir }
416cdf0e10cSrcweir // -------------------------------------------------------------------------
fillPropertyValues()417cdf0e10cSrcweir void OAdoIndex::fillPropertyValues()
418cdf0e10cSrcweir {
419cdf0e10cSrcweir 	if(m_aIndex.IsValid())
420cdf0e10cSrcweir 	{
421cdf0e10cSrcweir 		m_Name				= m_aIndex.get_Name();
422cdf0e10cSrcweir 		m_IsUnique			= m_aIndex.get_Unique();
423cdf0e10cSrcweir         m_IsPrimaryKeyIndex = m_aIndex.get_PrimaryKey();
424cdf0e10cSrcweir 		m_IsClustered		= m_aIndex.get_Clustered();
425cdf0e10cSrcweir 	}
426cdf0e10cSrcweir }
427cdf0e10cSrcweir // -----------------------------------------------------------------------------
Create()428cdf0e10cSrcweir void WpADOKey::Create()
429cdf0e10cSrcweir {
430cdf0e10cSrcweir 	HRESULT         hr = -1;
431cdf0e10cSrcweir 	_ADOKey* pKey = NULL;
432cdf0e10cSrcweir 	hr = CoCreateInstance(ADOS::CLSID_ADOKEY_25,
433cdf0e10cSrcweir 						  NULL,
434cdf0e10cSrcweir 						  CLSCTX_INPROC_SERVER,
435cdf0e10cSrcweir 						  ADOS::IID_ADOKEY_25,
436cdf0e10cSrcweir 						  (void**)&pKey );
437cdf0e10cSrcweir 
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 	if( !FAILED( hr ) )
440cdf0e10cSrcweir 	{
441cdf0e10cSrcweir 		operator=( pKey );
442cdf0e10cSrcweir 		pKey->Release();
443cdf0e10cSrcweir 	}
444cdf0e10cSrcweir }
445cdf0e10cSrcweir // -------------------------------------------------------------------------
fillPropertyValues()446cdf0e10cSrcweir void OAdoKey::fillPropertyValues()
447cdf0e10cSrcweir {
448cdf0e10cSrcweir 	if(m_aKey.IsValid())
449cdf0e10cSrcweir 	{
450cdf0e10cSrcweir 		m_aProps->m_Type			= MapKeyRule(m_aKey.get_Type());
451cdf0e10cSrcweir 		m_Name			            = m_aKey.get_Name();
452cdf0e10cSrcweir 		m_aProps->m_ReferencedTable	= m_aKey.get_RelatedTable();
453cdf0e10cSrcweir 		m_aProps->m_UpdateRule		= MapRule(m_aKey.get_UpdateRule());
454cdf0e10cSrcweir 		m_aProps->m_DeleteRule		= MapRule(m_aKey.get_DeleteRule());
455cdf0e10cSrcweir 	}
456cdf0e10cSrcweir }
457cdf0e10cSrcweir // -------------------------------------------------------------------------
MapRule(const RuleEnum & _eNum)458cdf0e10cSrcweir sal_Int32 OAdoKey::MapRule(const RuleEnum& _eNum)
459cdf0e10cSrcweir {
460cdf0e10cSrcweir         sal_Int32 eNum = KeyRule::NO_ACTION;
461cdf0e10cSrcweir 	switch(_eNum)
462cdf0e10cSrcweir 	{
463cdf0e10cSrcweir 		case adRICascade:
464cdf0e10cSrcweir 			eNum = KeyRule::CASCADE;
465cdf0e10cSrcweir 			break;
466cdf0e10cSrcweir 		case adRISetNull:
467cdf0e10cSrcweir             eNum = KeyRule::SET_NULL;
468cdf0e10cSrcweir 			break;
469cdf0e10cSrcweir 		case adRINone:
470cdf0e10cSrcweir             eNum = KeyRule::NO_ACTION;
471cdf0e10cSrcweir 			break;
472cdf0e10cSrcweir 		case adRISetDefault:
473cdf0e10cSrcweir             eNum = KeyRule::SET_DEFAULT;
474cdf0e10cSrcweir 			break;
475cdf0e10cSrcweir 	}
476cdf0e10cSrcweir 	return eNum;
477cdf0e10cSrcweir }
478cdf0e10cSrcweir // -------------------------------------------------------------------------
Map2Rule(const sal_Int32 & _eNum)479cdf0e10cSrcweir RuleEnum OAdoKey::Map2Rule(const sal_Int32& _eNum)
480cdf0e10cSrcweir {
481cdf0e10cSrcweir 	RuleEnum eNum = adRINone;
482cdf0e10cSrcweir 	switch(_eNum)
483cdf0e10cSrcweir 	{
484cdf0e10cSrcweir 		case KeyRule::CASCADE:
485cdf0e10cSrcweir 			eNum = adRICascade;
486cdf0e10cSrcweir 			break;
487cdf0e10cSrcweir         case KeyRule::SET_NULL:
488cdf0e10cSrcweir 			eNum = adRISetNull;
489cdf0e10cSrcweir 			break;
490cdf0e10cSrcweir         case KeyRule::NO_ACTION:
491cdf0e10cSrcweir 			eNum = adRINone;
492cdf0e10cSrcweir 			break;
493cdf0e10cSrcweir         case KeyRule::SET_DEFAULT:
494cdf0e10cSrcweir 			eNum = adRISetDefault;
495cdf0e10cSrcweir 			break;
496cdf0e10cSrcweir 	}
497cdf0e10cSrcweir 	return eNum;
498cdf0e10cSrcweir }
499cdf0e10cSrcweir // -------------------------------------------------------------------------
MapKeyRule(const KeyTypeEnum & _eNum)500cdf0e10cSrcweir sal_Int32 OAdoKey::MapKeyRule(const KeyTypeEnum& _eNum)
501cdf0e10cSrcweir {
502cdf0e10cSrcweir 	sal_Int32 nKeyType = KeyType::PRIMARY;
503cdf0e10cSrcweir 	switch(_eNum)
504cdf0e10cSrcweir 	{
505cdf0e10cSrcweir 		case adKeyPrimary:
506cdf0e10cSrcweir 			nKeyType = KeyType::PRIMARY;
507cdf0e10cSrcweir 			break;
508cdf0e10cSrcweir 		case adKeyForeign:
509cdf0e10cSrcweir 			nKeyType = KeyType::FOREIGN;
510cdf0e10cSrcweir 			break;
511cdf0e10cSrcweir 		case adKeyUnique:
512cdf0e10cSrcweir 			nKeyType = KeyType::UNIQUE;
513cdf0e10cSrcweir 			break;
514cdf0e10cSrcweir 	}
515cdf0e10cSrcweir 	return nKeyType;
516cdf0e10cSrcweir }
517cdf0e10cSrcweir // -------------------------------------------------------------------------
Map2KeyRule(const sal_Int32 & _eNum)518cdf0e10cSrcweir KeyTypeEnum OAdoKey::Map2KeyRule(const sal_Int32& _eNum)
519cdf0e10cSrcweir {
520cdf0e10cSrcweir     KeyTypeEnum eNum( adKeyPrimary );
521cdf0e10cSrcweir 	switch(_eNum)
522cdf0e10cSrcweir 	{
523cdf0e10cSrcweir 		case KeyType::PRIMARY:
524cdf0e10cSrcweir 			eNum = adKeyPrimary;
525cdf0e10cSrcweir 			break;
526cdf0e10cSrcweir         case KeyType::FOREIGN:
527cdf0e10cSrcweir 			eNum = adKeyForeign;
528cdf0e10cSrcweir 			break;
529cdf0e10cSrcweir         case KeyType::UNIQUE:
530cdf0e10cSrcweir 			eNum = adKeyUnique;
531cdf0e10cSrcweir 			break;
532cdf0e10cSrcweir         default:
533cdf0e10cSrcweir             OSL_ENSURE( false, "OAdoKey::Map2KeyRule: invalid key type!" );
534cdf0e10cSrcweir 	}
535cdf0e10cSrcweir 	return eNum;
536cdf0e10cSrcweir }
537cdf0e10cSrcweir // -----------------------------------------------------------------------------
Create()538cdf0e10cSrcweir void WpADOTable::Create()
539cdf0e10cSrcweir {
540cdf0e10cSrcweir 	HRESULT         hr = -1;
541cdf0e10cSrcweir 	_ADOTable* pTable = NULL;
542cdf0e10cSrcweir 	hr = CoCreateInstance(ADOS::CLSID_ADOTABLE_25,
543cdf0e10cSrcweir 						  NULL,
544cdf0e10cSrcweir 						  CLSCTX_INPROC_SERVER,
545cdf0e10cSrcweir 						  ADOS::IID_ADOTABLE_25,
546cdf0e10cSrcweir 						  (void**)&pTable );
547cdf0e10cSrcweir 
548cdf0e10cSrcweir 
549cdf0e10cSrcweir 	if( !FAILED( hr ) )
550cdf0e10cSrcweir 	{
551cdf0e10cSrcweir 		operator=( pTable );
552cdf0e10cSrcweir 		pTable->Release();
553cdf0e10cSrcweir 	}
554cdf0e10cSrcweir }
555cdf0e10cSrcweir // -------------------------------------------------------------------------
GetObjectOwner(const::rtl::OUString & _rName,ObjectTypeEnum _eNum)556cdf0e10cSrcweir ::rtl::OUString WpADOCatalog::GetObjectOwner(const ::rtl::OUString& _rName, ObjectTypeEnum _eNum)
557cdf0e10cSrcweir {
558cdf0e10cSrcweir 	OLEVariant _rVar;
559cdf0e10cSrcweir 	_rVar.setNoArg();
560cdf0e10cSrcweir 	OLEString aBSTR;
561cdf0e10cSrcweir 	OLEString sStr1(_rName);
562cdf0e10cSrcweir 	pInterface->GetObjectOwner(sStr1,_eNum,_rVar,&aBSTR);
563cdf0e10cSrcweir 	return aBSTR;
564cdf0e10cSrcweir }
565cdf0e10cSrcweir // -----------------------------------------------------------------------------
fillPropertyValues()566cdf0e10cSrcweir void OAdoTable::fillPropertyValues()
567cdf0e10cSrcweir {
568cdf0e10cSrcweir 	if(m_aTable.IsValid())
569cdf0e10cSrcweir 	{
570cdf0e10cSrcweir 		m_Name	= m_aTable.get_Name();
571cdf0e10cSrcweir 		m_Type	= m_aTable.get_Type();
572cdf0e10cSrcweir 		{
573cdf0e10cSrcweir 			WpADOCatalog aCat(m_aTable.get_ParentCatalog());
574cdf0e10cSrcweir 			if(aCat.IsValid())
575cdf0e10cSrcweir 				m_CatalogName = aCat.GetObjectOwner(m_aTable.get_Name(),adPermObjTable);
576cdf0e10cSrcweir 		}
577cdf0e10cSrcweir 		{
578cdf0e10cSrcweir 			WpADOProperties aProps = m_aTable.get_Properties();
579cdf0e10cSrcweir 			if(aProps.IsValid())
580cdf0e10cSrcweir 				m_Description = OTools::getValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Description")));
581cdf0e10cSrcweir 		}
582cdf0e10cSrcweir 	}
583cdf0e10cSrcweir }
584cdf0e10cSrcweir // -----------------------------------------------------------------------------
Create()585cdf0e10cSrcweir void WpADOUser::Create()
586cdf0e10cSrcweir {
587cdf0e10cSrcweir 	HRESULT         hr = -1;
588cdf0e10cSrcweir 	_ADOUser* pUser = NULL;
589cdf0e10cSrcweir 	hr = CoCreateInstance(ADOS::CLSID_ADOUSER_25,
590cdf0e10cSrcweir 						  NULL,
591cdf0e10cSrcweir 						  CLSCTX_INPROC_SERVER,
592cdf0e10cSrcweir 						  ADOS::IID_ADOUSER_25,
593cdf0e10cSrcweir 						  (void**)&pUser );
594cdf0e10cSrcweir 
595cdf0e10cSrcweir 
596cdf0e10cSrcweir 	if( !FAILED( hr ) )
597cdf0e10cSrcweir 	{
598cdf0e10cSrcweir 		operator=( pUser );
599cdf0e10cSrcweir 		pUser->Release();
600cdf0e10cSrcweir 	}
601cdf0e10cSrcweir }
602cdf0e10cSrcweir // -------------------------------------------------------------------------
603cdf0e10cSrcweir 
604cdf0e10cSrcweir 
605