bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / ado / ADatabaseMetaDataResultSetMetaData.cxx
blob9a4365abfcce4d058efc23f108b519c3229bf10d
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 #include <ado/ADatabaseMetaDataResultSetMetaData.hxx>
21 #include <ado/Awrapado.hxx>
22 #include <connectivity/dbexception.hxx>
25 using namespace connectivity;
26 using namespace connectivity::ado;
27 using namespace com::sun::star::uno;
28 using namespace com::sun::star::lang;
29 using namespace com::sun::star::beans;
30 using namespace com::sun::star::sdbc;
33 ODatabaseMetaDataResultSetMetaData::~ODatabaseMetaDataResultSetMetaData()
35 if(m_pRecordSet)
36 m_pRecordSet->Release();
39 sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnDisplaySize( sal_Int32 column )
41 sal_Int32 nSize = 0;
42 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
43 nSize = (*m_mColumnsIter).second.getColumnDisplaySize();
44 else if(m_pRecordSet)
46 WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
47 if(aField.IsValid())
48 nSize = aField.GetActualSize();
50 return nSize;
54 sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnType( sal_Int32 column )
56 sal_Int32 nType = 0;
57 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
58 nType = (*m_mColumnsIter).second.getColumnType();
59 else if(m_pRecordSet)
61 WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
62 nType = ADOS::MapADOType2Jdbc(aField.GetADOType());
64 return nType;
68 sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnCount( )
70 if(!m_pRecordSet)
71 return 0;
72 if(m_nColCount != -1)
73 return m_nColCount;
75 if(m_vMapping.size())
76 return m_mColumns.size();
78 ADOFields* pFields = nullptr;
79 m_pRecordSet->get_Fields(&pFields);
80 WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(pFields);
81 m_nColCount = aFields.GetItemCount();
82 return m_nColCount;
86 OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnName( sal_Int32 column )
88 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
89 return (*m_mColumnsIter).second.getColumnName();
90 if(!m_pRecordSet)
91 return OUString();
92 WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
93 if(aField.IsValid())
94 return aField.GetName();
96 return OUString();
99 OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnLabel( sal_Int32 column )
101 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
102 return (*m_mColumnsIter).second.getColumnLabel();
103 return getColumnName(column);
107 sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isCurrency( sal_Int32 column )
109 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
110 return (*m_mColumnsIter).second.isCurrency();
111 if(!m_pRecordSet)
112 return false;
113 WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
114 if(aField.IsValid())
116 return (aField.GetAttributes() & adFldFixed) == adFldFixed;
118 return false;
122 sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isSigned( sal_Int32 column )
124 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
125 return (*m_mColumnsIter).second.isSigned();
126 if(!m_pRecordSet)
127 return false;
128 WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
129 if(aField.IsValid())
131 return (aField.GetAttributes() & adFldNegativeScale) == adFldNegativeScale;
133 return false;
136 sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getPrecision( sal_Int32 column )
138 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
139 return (*m_mColumnsIter).second.getPrecision();
140 if(!m_pRecordSet)
141 return 0;
142 WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
143 if(aField.IsValid())
144 return aField.GetPrecision();
145 return 0;
148 sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getScale( sal_Int32 column )
150 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
151 return (*m_mColumnsIter).second.getScale();
153 if(!m_pRecordSet)
154 return 0;
156 WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
157 if(aField.IsValid())
158 return aField.GetNumericScale();
159 return 0;
163 sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::isNullable( sal_Int32 column )
165 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
166 return (*m_mColumnsIter).second.isNullable();
168 if(!m_pRecordSet)
169 return sal_Int32(false);
171 WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
172 if(aField.IsValid())
174 return sal_Int32((aField.GetAttributes() & adFldIsNullable) == adFldIsNullable);
176 return sal_Int32(false);
180 sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isReadOnly( sal_Int32 column )
182 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
183 return (*m_mColumnsIter).second.isReadOnly();
185 if(!m_pRecordSet)
186 return false;
188 WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
189 if(aField.IsValid())
191 // return (aField.GetStatus() & adFieldReadOnly) == adFieldReadOnly;
193 return false;
197 sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isDefinitelyWritable( sal_Int32 column )
199 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
200 return (*m_mColumnsIter).second.isDefinitelyWritable();
202 if(!m_pRecordSet)
203 return false;
205 WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
206 if(aField.IsValid())
208 return (aField.GetAttributes() & adFldUpdatable) == adFldUpdatable;
210 return false;
214 sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isWritable( sal_Int32 column )
216 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
217 return (*m_mColumnsIter).second.isWritable();
218 return isDefinitelyWritable(column);
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */