1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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()
36 m_pRecordSet
->Release();
39 sal_Int32 SAL_CALL
ODatabaseMetaDataResultSetMetaData::getColumnDisplaySize( sal_Int32 column
)
42 if(m_mColumns
.size() && (m_mColumnsIter
= m_mColumns
.find(column
)) != m_mColumns
.end())
43 nSize
= (*m_mColumnsIter
).second
.getColumnDisplaySize();
46 WpADOField aField
= ADOS::getField(m_pRecordSet
,m_vMapping
[column
]);
48 nSize
= aField
.GetActualSize();
54 sal_Int32 SAL_CALL
ODatabaseMetaDataResultSetMetaData::getColumnType( sal_Int32 column
)
57 if(m_mColumns
.size() && (m_mColumnsIter
= m_mColumns
.find(column
)) != m_mColumns
.end())
58 nType
= (*m_mColumnsIter
).second
.getColumnType();
61 WpADOField aField
= ADOS::getField(m_pRecordSet
,m_vMapping
[column
]);
62 nType
= ADOS::MapADOType2Jdbc(aField
.GetADOType());
68 sal_Int32 SAL_CALL
ODatabaseMetaDataResultSetMetaData::getColumnCount( )
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();
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();
92 WpADOField aField
= ADOS::getField(m_pRecordSet
,m_vMapping
[column
]);
94 return aField
.GetName();
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();
113 WpADOField aField
= ADOS::getField(m_pRecordSet
,m_vMapping
[column
]);
116 return (aField
.GetAttributes() & adFldFixed
) == adFldFixed
;
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();
128 WpADOField aField
= ADOS::getField(m_pRecordSet
,m_vMapping
[column
]);
131 return (aField
.GetAttributes() & adFldNegativeScale
) == adFldNegativeScale
;
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();
142 WpADOField aField
= ADOS::getField(m_pRecordSet
,m_vMapping
[column
]);
144 return aField
.GetPrecision();
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();
156 WpADOField aField
= ADOS::getField(m_pRecordSet
,m_vMapping
[column
]);
158 return aField
.GetNumericScale();
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();
169 return sal_Int32(false);
171 WpADOField aField
= ADOS::getField(m_pRecordSet
,m_vMapping
[column
]);
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();
188 WpADOField aField
= ADOS::getField(m_pRecordSet
,m_vMapping
[column
]);
191 // return (aField.GetStatus() & adFieldReadOnly) == adFieldReadOnly;
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();
205 WpADOField aField
= ADOS::getField(m_pRecordSet
,m_vMapping
[column
]);
208 return (aField
.GetAttributes() & adFldUpdatable
) == adFldUpdatable
;
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: */