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 "NResultSetMetaData.hxx"
21 #include "NDatabaseMetaData.hxx"
22 #include <connectivity/dbexception.hxx>
23 #include <strings.hrc>
26 using namespace connectivity::evoab
;
27 using namespace com::sun::star::uno
;
28 using namespace com::sun::star::lang
;
29 using namespace com::sun::star::sdbc
;
31 OEvoabResultSetMetaData::OEvoabResultSetMetaData(OUString _aTableName
)
32 : m_aTableName(std::move(_aTableName
))
37 OEvoabResultSetMetaData::~OEvoabResultSetMetaData()
41 void OEvoabResultSetMetaData::setEvoabFields(const ::rtl::Reference
<connectivity::OSQLColumns
> &xColumns
)
43 static constexpr OUStringLiteral aName
= u
"Name";
45 for (const auto& rxColumn
: *xColumns
)
49 rxColumn
->getPropertyValue(aName
) >>= aFieldName
;
50 guint nFieldNumber
= findEvoabField(aFieldName
);
51 if (nFieldNumber
== guint(-1))
53 connectivity::SharedResources aResource
;
54 const OUString
sError( aResource
.getResourceStringWithSubstitution(
55 STR_INVALID_COLUMNNAME
,
56 "$columnname$", aFieldName
58 ::dbtools::throwGenericSQLException( sError
, *this );
60 m_aEvoabFields
.push_back(nFieldNumber
);
65 sal_Int32 SAL_CALL
OEvoabResultSetMetaData::getColumnDisplaySize( sal_Int32
/*nColumnNum*/ )
70 sal_Int32 SAL_CALL
OEvoabResultSetMetaData::getColumnType( sal_Int32 nColumnNum
)
72 sal_uInt32 nField
= m_aEvoabFields
[nColumnNum
- 1];
73 return evoab::getFieldType (nField
);
76 sal_Int32 SAL_CALL
OEvoabResultSetMetaData::getColumnCount( )
78 return m_aEvoabFields
.size();
81 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isCaseSensitive( sal_Int32
/*nColumnNum*/ )
86 OUString SAL_CALL
OEvoabResultSetMetaData::getSchemaName( sal_Int32
/*nColumnNum*/ )
91 OUString SAL_CALL
OEvoabResultSetMetaData::getColumnName( sal_Int32 nColumnNum
)
93 sal_uInt32 nField
= m_aEvoabFields
[nColumnNum
- 1];
94 return evoab::getFieldName( nField
);
97 OUString SAL_CALL
OEvoabResultSetMetaData::getColumnTypeName( sal_Int32 nColumnNum
)
99 sal_uInt32 nField
= m_aEvoabFields
[nColumnNum
- 1];
100 return evoab::getFieldTypeName( nField
);
103 OUString SAL_CALL
OEvoabResultSetMetaData::getColumnLabel( sal_Int32 nColumnNum
)
105 return getColumnName(nColumnNum
);
108 OUString SAL_CALL
OEvoabResultSetMetaData::getColumnServiceName( sal_Int32
/*nColumnNum*/ )
113 OUString SAL_CALL
OEvoabResultSetMetaData::getTableName( sal_Int32
/*nColumnNum*/ )
115 return m_aTableName
;//OUString("TABLE");
118 OUString SAL_CALL
OEvoabResultSetMetaData::getCatalogName( sal_Int32
/*nColumnNum*/ )
124 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isCurrency( sal_Int32
/*nColumnNum*/ )
129 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isAutoIncrement( sal_Int32
/*nColumnNum*/ )
134 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isSigned( sal_Int32
/*nColumnNum*/ )
139 sal_Int32 SAL_CALL
OEvoabResultSetMetaData::getPrecision( sal_Int32
/*nColumnNum*/ )
144 sal_Int32 SAL_CALL
OEvoabResultSetMetaData::getScale( sal_Int32
/*nColumnNum*/ )
149 sal_Int32 SAL_CALL
OEvoabResultSetMetaData::isNullable( sal_Int32
/*nColumnNum*/ )
154 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isSearchable( sal_Int32
/*nColumnNum*/ )
159 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isReadOnly( sal_Int32
/*nColumnNum*/ )
164 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isDefinitelyWritable( sal_Int32
/*nColumnNum*/ )
169 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isWritable( sal_Int32
/*nColumnNum*/ )
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */