LibreOffice Module connectivity (master) 1
NResultSetMetaData.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 "NDatabaseMetaData.hxx"
23#include <strings.hrc>
24#include <utility>
25
26using namespace connectivity::evoab;
27using namespace com::sun::star::uno;
28using namespace com::sun::star::lang;
29using namespace com::sun::star::sdbc;
30
31OEvoabResultSetMetaData::OEvoabResultSetMetaData(OUString _aTableName)
32 : m_aTableName(std::move(_aTableName))
33{
34
35}
36
38{
39}
40
41void OEvoabResultSetMetaData::setEvoabFields(const ::rtl::Reference<connectivity::OSQLColumns> &xColumns)
42{
43 static constexpr OUStringLiteral aName = u"Name";
44
45 for (const auto& rxColumn : *xColumns)
46 {
47 OUString aFieldName;
48
49 rxColumn->getPropertyValue(aName) >>= aFieldName;
50 guint nFieldNumber = findEvoabField(aFieldName);
51 if (nFieldNumber == guint(-1))
52 {
54 const OUString sError( aResource.getResourceStringWithSubstitution(
55 STR_INVALID_COLUMNNAME,
56 "$columnname$", aFieldName
57 ) );
59 }
60 m_aEvoabFields.push_back(nFieldNumber);
61 }
62}
63
64
65sal_Int32 SAL_CALL OEvoabResultSetMetaData::getColumnDisplaySize( sal_Int32 /*nColumnNum*/ )
66{
67 return 50;
68}
69
70sal_Int32 SAL_CALL OEvoabResultSetMetaData::getColumnType( sal_Int32 nColumnNum )
71{
72 sal_uInt32 nField = m_aEvoabFields[nColumnNum - 1];
73 return evoab::getFieldType (nField);
74}
75
77{
78 return m_aEvoabFields.size();
79}
80
81sal_Bool SAL_CALL OEvoabResultSetMetaData::isCaseSensitive( sal_Int32 /*nColumnNum*/ )
82{
83 return true;
84}
85
86OUString SAL_CALL OEvoabResultSetMetaData::getSchemaName( sal_Int32 /*nColumnNum*/ )
87{
88 return OUString();
89}
90
91OUString SAL_CALL OEvoabResultSetMetaData::getColumnName( sal_Int32 nColumnNum )
92{
93 sal_uInt32 nField = m_aEvoabFields[nColumnNum - 1];
94 return evoab::getFieldName( nField );
95}
96
97OUString SAL_CALL OEvoabResultSetMetaData::getColumnTypeName( sal_Int32 nColumnNum )
98{
99 sal_uInt32 nField = m_aEvoabFields[nColumnNum - 1];
100 return evoab::getFieldTypeName( nField );
101}
102
103OUString SAL_CALL OEvoabResultSetMetaData::getColumnLabel( sal_Int32 nColumnNum )
104{
105 return getColumnName(nColumnNum);
106}
107
108OUString SAL_CALL OEvoabResultSetMetaData::getColumnServiceName( sal_Int32 /*nColumnNum*/ )
109{
110 return OUString();
111}
112
113OUString SAL_CALL OEvoabResultSetMetaData::getTableName( sal_Int32 /*nColumnNum*/ )
114{
115 return m_aTableName;//OUString("TABLE");
116}
117
118OUString SAL_CALL OEvoabResultSetMetaData::getCatalogName( sal_Int32 /*nColumnNum*/ )
119{
120 return OUString();
121}
122
123
124sal_Bool SAL_CALL OEvoabResultSetMetaData::isCurrency( sal_Int32 /*nColumnNum*/ )
125{
126 return false;
127}
128
129sal_Bool SAL_CALL OEvoabResultSetMetaData::isAutoIncrement( sal_Int32 /*nColumnNum*/ )
130{
131 return false;
132}
133
134sal_Bool SAL_CALL OEvoabResultSetMetaData::isSigned( sal_Int32 /*nColumnNum*/ )
135{
136 return false;
137}
138
139sal_Int32 SAL_CALL OEvoabResultSetMetaData::getPrecision( sal_Int32 /*nColumnNum*/ )
140{
141 return 0;
142}
143
144sal_Int32 SAL_CALL OEvoabResultSetMetaData::getScale( sal_Int32 /*nColumnNum*/ )
145{
146 return 0;
147}
148
149sal_Int32 SAL_CALL OEvoabResultSetMetaData::isNullable( sal_Int32 /*nColumnNum*/ )
150{
151 return 0;
152}
153
154sal_Bool SAL_CALL OEvoabResultSetMetaData::isSearchable( sal_Int32 /*nColumnNum*/ )
155{
156 return true;
157}
158
159sal_Bool SAL_CALL OEvoabResultSetMetaData::isReadOnly( sal_Int32 /*nColumnNum*/ )
160{
161 return true;
162}
163
164sal_Bool SAL_CALL OEvoabResultSetMetaData::isDefinitelyWritable( sal_Int32 /*nColumnNum*/ )
165{
166 return false;
167}
168
169sal_Bool SAL_CALL OEvoabResultSetMetaData::isWritable( sal_Int32 /*nColumnNum*/ )
170{
171 return false;
172}
173
174
175/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
helper class for accessing resources shared by different libraries in the connectivity module
OUString getResourceStringWithSubstitution(TranslateId pResId, const char *_pAsciiPatternToReplace, const OUString &_rStringToSubstitute) const
loads a string from the shared resource file, and replaces a given ASCII pattern with a given string
virtual OUString SAL_CALL getColumnName(sal_Int32 column) override
virtual sal_Bool SAL_CALL isAutoIncrement(sal_Int32 column) override
virtual OUString SAL_CALL getCatalogName(sal_Int32 column) override
virtual OUString SAL_CALL getSchemaName(sal_Int32 column) override
void setEvoabFields(const ::rtl::Reference< connectivity::OSQLColumns > &xColumns)
virtual OUString SAL_CALL getColumnTypeName(sal_Int32 column) override
virtual OUString SAL_CALL getColumnServiceName(sal_Int32 column) override
virtual sal_Bool SAL_CALL isDefinitelyWritable(sal_Int32 column) override
virtual sal_Int32 SAL_CALL getScale(sal_Int32 column) override
virtual sal_Int32 SAL_CALL getPrecision(sal_Int32 column) override
virtual OUString SAL_CALL getTableName(sal_Int32 column) override
virtual sal_Bool SAL_CALL isReadOnly(sal_Int32 column) override
virtual sal_Bool SAL_CALL isCurrency(sal_Int32 column) override
virtual sal_Int32 SAL_CALL getColumnType(sal_Int32 column) override
virtual sal_Int32 SAL_CALL getColumnCount() override
virtual OUString SAL_CALL getColumnLabel(sal_Int32 column) override
virtual sal_Bool SAL_CALL isWritable(sal_Int32 column) override
virtual sal_Int32 SAL_CALL getColumnDisplaySize(sal_Int32 column) override
virtual sal_Int32 SAL_CALL isNullable(sal_Int32 column) override
virtual sal_Bool SAL_CALL isSigned(sal_Int32 column) override
virtual sal_Bool SAL_CALL isCaseSensitive(sal_Int32 column) override
virtual sal_Bool SAL_CALL isSearchable(sal_Int32 column) override
float u
OUString aName
sal_Int32 getFieldType(guint nCol)
OUString getFieldName(guint nCol)
guint findEvoabField(std::u16string_view aColName)
OUString getFieldTypeName(guint nCol)
void throwGenericSQLException(const OUString &_rMsg, const css::uno::Reference< css::uno::XInterface > &_rxSource)
throw a generic SQLException, i.e.
unsigned char sal_Bool