LibreOffice Module connectivity (master) 1
ADatabaseMetaDataResultSetMetaData.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21#include <ado/Awrapado.hxx>
23
24using namespace connectivity;
25using namespace connectivity::ado;
26using namespace com::sun::star::uno;
27using namespace com::sun::star::lang;
28using namespace com::sun::star::beans;
29using namespace com::sun::star::sdbc;
30
31ODatabaseMetaDataResultSetMetaData::~ODatabaseMetaDataResultSetMetaData()
32{
33 if (m_pRecordSet)
34 m_pRecordSet->Release();
35}
36
38{
39 sal_Int32 nSize = 0;
40 if (m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
41 nSize = (*m_mColumnsIter).second.getColumnDisplaySize();
42 else if (m_pRecordSet)
43 {
45 if (aField.IsValid())
46 nSize = aField.GetActualSize();
47 }
48 return nSize;
49}
50
51sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnType(sal_Int32 column)
52{
53 sal_Int32 nType = 0;
54 if (m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
55 nType = (*m_mColumnsIter).second.getColumnType();
56 else if (m_pRecordSet)
57 {
60 }
61 return nType;
62}
63
65{
66 if (!m_pRecordSet)
67 return 0;
68 if (m_nColCount != -1)
69 return m_nColCount;
70
71 if (m_vMapping.size())
72 return m_mColumns.size();
73
75 m_pRecordSet->get_Fields(&aFields);
76 m_nColCount = aFields.GetItemCount();
77 return m_nColCount;
78}
79
80OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnName(sal_Int32 column)
81{
82 if (m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
83 return (*m_mColumnsIter).second.getColumnName();
84 if (!m_pRecordSet)
85 return OUString();
87 if (aField.IsValid())
88 return aField.GetName();
89
90 return OUString();
91}
92
93OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnLabel(sal_Int32 column)
94{
95 if (m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
96 return (*m_mColumnsIter).second.getColumnLabel();
97 return getColumnName(column);
98}
99
101{
102 if (m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
103 return (*m_mColumnsIter).second.isCurrency();
104 if (!m_pRecordSet)
105 return false;
107 if (aField.IsValid())
108 {
109 return (aField.GetAttributes() & adFldFixed) == adFldFixed;
110 }
111 return false;
112}
113
115{
116 if (m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
117 return (*m_mColumnsIter).second.isSigned();
118 if (!m_pRecordSet)
119 return false;
121 if (aField.IsValid())
122 {
123 return (aField.GetAttributes() & adFldNegativeScale) == adFldNegativeScale;
124 }
125 return false;
126}
127
128sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getPrecision(sal_Int32 column)
129{
130 if (m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
131 return (*m_mColumnsIter).second.getPrecision();
132 if (!m_pRecordSet)
133 return 0;
135 if (aField.IsValid())
136 return aField.GetPrecision();
137 return 0;
138}
139
140sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getScale(sal_Int32 column)
141{
142 if (m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
143 return (*m_mColumnsIter).second.getScale();
144
145 if (!m_pRecordSet)
146 return 0;
147
149 if (aField.IsValid())
150 return aField.GetNumericScale();
151 return 0;
152}
153
154sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::isNullable(sal_Int32 column)
155{
156 if (m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
157 return (*m_mColumnsIter).second.isNullable();
158
159 if (!m_pRecordSet)
160 return sal_Int32(false);
161
163 if (aField.IsValid())
164 {
165 return sal_Int32((aField.GetAttributes() & adFldIsNullable) == adFldIsNullable);
166 }
167 return sal_Int32(false);
168}
169
171{
172 if (m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
173 return (*m_mColumnsIter).second.isReadOnly();
174
175 if (!m_pRecordSet)
176 return false;
177
179 if (aField.IsValid())
180 {
181 // return (aField.GetStatus() & adFieldReadOnly) == adFieldReadOnly;
182 }
183 return false;
184}
185
187{
188 if (m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
189 return (*m_mColumnsIter).second.isDefinitelyWritable();
190
191 if (!m_pRecordSet)
192 return false;
193
195 if (aField.IsValid())
196 {
197 return (aField.GetAttributes() & adFldUpdatable) == adFldUpdatable;
198 }
199 return false;
200 ;
201}
202
204{
205 if (m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
206 return (*m_mColumnsIter).second.isWritable();
207 return isDefinitelyWritable(column);
208}
209
210/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static sal_Int32 MapADOType2Jdbc(DataTypeEnum eType)
Definition: adoimp.cxx:78
static WpADOField getField(ADORecordset *_pRecordSet, sal_Int32 _nColumnIndex)
Definition: adoimp.cxx:309
virtual sal_Bool SAL_CALL isReadOnly(sal_Int32 column) override
virtual sal_Bool SAL_CALL isWritable(sal_Int32 column) override
virtual sal_Bool SAL_CALL isSigned(sal_Int32 column) override
virtual sal_Int32 SAL_CALL isNullable(sal_Int32 column) override
virtual sal_Int32 SAL_CALL getColumnDisplaySize(sal_Int32 column) override
virtual OUString SAL_CALL getColumnName(sal_Int32 column) override
std::map< sal_Int32, connectivity::OColumn >::const_iterator m_mColumnsIter
virtual sal_Int32 SAL_CALL getPrecision(sal_Int32 column) override
virtual sal_Int32 SAL_CALL getColumnType(sal_Int32 column) override
virtual OUString SAL_CALL getColumnLabel(sal_Int32 column) override
virtual sal_Int32 SAL_CALL getScale(sal_Int32 column) override
virtual sal_Bool SAL_CALL isCurrency(sal_Int32 column) override
virtual sal_Bool SAL_CALL isDefinitelyWritable(sal_Int32 column) override
DataTypeEnum GetADOType() const
Definition: Awrapado.cxx:478
OUString GetName() const
Definition: Awrapado.cxx:470
sal_Int32 GetActualSize() const
Definition: Awrapado.cxx:438
sal_Int32 GetPrecision() const
Definition: Awrapado.cxx:507
sal_Int32 GetNumericScale() const
Definition: Awrapado.cxx:515
sal_Int32 GetAttributes() const
Definition: Awrapado.cxx:446
sal_Int32 GetItemCount() const
Definition: Aolewrap.hxx:96
QPRO_FUNC_TYPE nType
unsigned char sal_Bool