LibreOffice Module connectivity (master) 1
FResultSetMetaData.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 <file/FTable.hxx>
24#include <comphelper/types.hxx>
25#include <o3tl/safeint.hxx>
26#include <utility>
27
28
29using namespace ::comphelper;
30using namespace connectivity;
31using namespace dbtools;
32using namespace connectivity::file;
33using namespace ::com::sun::star::beans;
34using namespace ::com::sun::star::uno;
35using namespace ::com::sun::star::sdbcx;
36using namespace ::com::sun::star::sdbc;
37using namespace ::com::sun::star::container;
38using namespace ::com::sun::star::lang;
39
40
41OResultSetMetaData::OResultSetMetaData(::rtl::Reference<connectivity::OSQLColumns> _xColumns, OUString _aTableName, OFileTable* _pTable)
42 :m_aTableName(std::move(_aTableName))
43 ,m_xColumns(std::move(_xColumns))
44 ,m_pTable(_pTable)
45{
46}
47
48
50{
51 m_xColumns = nullptr;
52}
53
55{
56 if(column <= 0 || o3tl::make_unsigned(column) > m_xColumns->size())
58}
59
60sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column )
61{
62 return getPrecision(column);
63}
64
65
66sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 column )
67{
68 checkColumnIndex(column);
70}
71
72
74{
75 return m_xColumns->size();
76}
77
78
79sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 /*column*/ )
80{
81 return false;
82}
83
84
85OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 /*column*/ )
86{
87 return OUString();
88}
89
90
91OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column )
92{
93 checkColumnIndex(column);
94
96 return aName.hasValue() ? getString(aName) : getString((*m_xColumns)[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)));
97}
98
99OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 /*column*/ )
100{
101 return m_aTableName;
102}
103
104OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 /*column*/ )
105{
106 return OUString();
107}
108
109OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column )
110{
111 checkColumnIndex(column);
113}
114
115OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column )
116{
117 return getColumnName(column);
118}
119
120OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 /*column*/ )
121{
122 return OUString();
123}
124
125
126sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column )
127{
128 checkColumnIndex(column);
130}
131
132
133sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 /*setCatalogcolumn*/ )
134{
135 return false;
136}
137
138sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 /*column*/ )
139{
140 return true;
141}
142
143sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column )
144{
145 checkColumnIndex(column);
147}
148
149sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column )
150{
151 checkColumnIndex(column);
153}
154
155
156sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column )
157{
158 checkColumnIndex(column);
160}
161
162
163sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 /*column*/ )
164{
165 return true;
166}
167
168
169sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column )
170{
171 checkColumnIndex(column);
172 return m_pTable->isReadOnly() || (
173 (*m_xColumns)[column-1]->getPropertySetInfo()->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION)) &&
174 ::cppu::any2bool((*m_xColumns)[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION))));
175}
176
177
179{
180 return !isReadOnly(column);
181}
182
183sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column )
184{
185 return !isReadOnly(column);
186}
187
188
189/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::dbtools::OPropertyMap & getPropMap()
Definition: TConnection.cxx:68
virtual sal_Bool SAL_CALL isSearchable(sal_Int32 column) override
virtual sal_Int32 SAL_CALL getPrecision(sal_Int32 column) override
virtual OUString SAL_CALL getSchemaName(sal_Int32 column) override
virtual sal_Bool SAL_CALL isCaseSensitive(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 OUString SAL_CALL getColumnTypeName(sal_Int32 column) override
virtual sal_Bool SAL_CALL isReadOnly(sal_Int32 column) override
virtual OUString SAL_CALL getColumnLabel(sal_Int32 column) override
virtual sal_Bool SAL_CALL isWritable(sal_Int32 column) override
virtual sal_Bool SAL_CALL isAutoIncrement(sal_Int32 column) override
::rtl::Reference< connectivity::OSQLColumns > m_xColumns
virtual OUString SAL_CALL getCatalogName(sal_Int32 column) override
virtual sal_Int32 SAL_CALL isNullable(sal_Int32 column) override
virtual OUString SAL_CALL getColumnServiceName(sal_Int32 column) override
virtual sal_Bool SAL_CALL isSigned(sal_Int32 column) override
virtual OUString SAL_CALL getTableName(sal_Int32 column) override
virtual sal_Int32 SAL_CALL getColumnCount() override
virtual OUString SAL_CALL getColumnName(sal_Int32 column) override
virtual sal_Int32 SAL_CALL getScale(sal_Int32 column) override
virtual sal_Int32 SAL_CALL getColumnDisplaySize(sal_Int32 column) override
virtual sal_Bool SAL_CALL isDefinitelyWritable(sal_Int32 column) override
OUString aName
bool getBOOL(const Any &_rAny)
sal_Int32 getINT32(const Any &_rAny)
OUString getString(const Any &_rAny)
void throwInvalidIndexException(const css::uno::Reference< css::uno::XInterface > &Context, const css::uno::Any &Next)
throw an invalid index sqlexception
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
#define PROPERTY_ID_NAME
Definition: propertyids.hxx:50
#define PROPERTY_ID_TYPE
Definition: propertyids.hxx:51
#define PROPERTY_ID_ISNULLABLE
Definition: propertyids.hxx:55
#define PROPERTY_ID_FUNCTION
Definition: propertyids.hxx:77
#define PROPERTY_ID_PRECISION
Definition: propertyids.hxx:53
#define PROPERTY_ID_ISCURRENCY
Definition: propertyids.hxx:81
#define PROPERTY_ID_TYPENAME
Definition: propertyids.hxx:52
#define PROPERTY_ID_SCALE
Definition: propertyids.hxx:54
unsigned char sal_Bool