1*9b5730f6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*9b5730f6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*9b5730f6SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*9b5730f6SAndrew Rist * distributed with this work for additional information
6*9b5730f6SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*9b5730f6SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*9b5730f6SAndrew Rist * "License"); you may not use this file except in compliance
9*9b5730f6SAndrew Rist * with the License. You may obtain a copy of the License at
10*9b5730f6SAndrew Rist *
11*9b5730f6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*9b5730f6SAndrew Rist *
13*9b5730f6SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*9b5730f6SAndrew Rist * software distributed under the License is distributed on an
15*9b5730f6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9b5730f6SAndrew Rist * KIND, either express or implied. See the License for the
17*9b5730f6SAndrew Rist * specific language governing permissions and limitations
18*9b5730f6SAndrew Rist * under the License.
19*9b5730f6SAndrew Rist *
20*9b5730f6SAndrew Rist *************************************************************/
21*9b5730f6SAndrew Rist
22*9b5730f6SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
26cdf0e10cSrcweir #include "NResultSetMetaData.hxx"
27cdf0e10cSrcweir #include "NDatabaseMetaData.hxx"
28cdf0e10cSrcweir #include "connectivity/dbexception.hxx"
29cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp>
30cdf0e10cSrcweir #include "NDebug.hxx"
31cdf0e10cSrcweir #include "resource/evoab2_res.hrc"
32cdf0e10cSrcweir
33cdf0e10cSrcweir using namespace connectivity::evoab;
34cdf0e10cSrcweir using namespace com::sun::star::uno;
35cdf0e10cSrcweir using namespace com::sun::star::lang;
36cdf0e10cSrcweir using namespace com::sun::star::sdbc;
37cdf0e10cSrcweir
OEvoabResultSetMetaData(const::rtl::OUString & _aTableName)38cdf0e10cSrcweir OEvoabResultSetMetaData::OEvoabResultSetMetaData(const ::rtl::OUString& _aTableName)
39cdf0e10cSrcweir : m_aTableName(_aTableName),
40cdf0e10cSrcweir m_aEvoabFields()
41cdf0e10cSrcweir {
42cdf0e10cSrcweir
43cdf0e10cSrcweir }
44cdf0e10cSrcweir // -------------------------------------------------------------------------
~OEvoabResultSetMetaData()45cdf0e10cSrcweir OEvoabResultSetMetaData::~OEvoabResultSetMetaData()
46cdf0e10cSrcweir {
47cdf0e10cSrcweir }
48cdf0e10cSrcweir // -------------------------------------------------------------------------
setEvoabFields(const::vos::ORef<connectivity::OSQLColumns> & xColumns)49cdf0e10cSrcweir void OEvoabResultSetMetaData::setEvoabFields(const ::vos::ORef<connectivity::OSQLColumns> &xColumns) throw(SQLException)
50cdf0e10cSrcweir {
51cdf0e10cSrcweir OSQLColumns::Vector::const_iterator aIter;
52cdf0e10cSrcweir static const ::rtl::OUString aName(::rtl::OUString::createFromAscii("Name"));
53cdf0e10cSrcweir
54cdf0e10cSrcweir for (aIter = xColumns->get().begin(); aIter != xColumns->get().end(); ++aIter)
55cdf0e10cSrcweir {
56cdf0e10cSrcweir ::rtl::OUString aFieldName;
57cdf0e10cSrcweir
58cdf0e10cSrcweir (*aIter)->getPropertyValue(aName) >>= aFieldName;
59cdf0e10cSrcweir guint nFieldNumber = findEvoabField(aFieldName);
60cdf0e10cSrcweir if (nFieldNumber == (guint)-1)
61cdf0e10cSrcweir {
62cdf0e10cSrcweir connectivity::SharedResources aResource;
63cdf0e10cSrcweir const ::rtl::OUString sError( aResource.getResourceStringWithSubstitution(
64cdf0e10cSrcweir STR_INVALID_COLUMNNAME,
65cdf0e10cSrcweir "$columnname$", aFieldName
66cdf0e10cSrcweir ) );
67cdf0e10cSrcweir ::dbtools::throwGenericSQLException( sError, *this );
68cdf0e10cSrcweir }
69cdf0e10cSrcweir m_aEvoabFields.push_back(nFieldNumber);
70cdf0e10cSrcweir }
71cdf0e10cSrcweir }
72cdf0e10cSrcweir
73cdf0e10cSrcweir // -------------------------------------------------------------------------
getColumnDisplaySize(sal_Int32)74cdf0e10cSrcweir sal_Int32 SAL_CALL OEvoabResultSetMetaData::getColumnDisplaySize( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
75cdf0e10cSrcweir {
76cdf0e10cSrcweir return 50;
77cdf0e10cSrcweir }
78cdf0e10cSrcweir // -------------------------------------------------------------------------
getColumnType(sal_Int32 nColumnNum)79cdf0e10cSrcweir sal_Int32 SAL_CALL OEvoabResultSetMetaData::getColumnType( sal_Int32 nColumnNum ) throw(SQLException, RuntimeException)
80cdf0e10cSrcweir {
81cdf0e10cSrcweir sal_uInt32 nField = m_aEvoabFields[nColumnNum - 1];
82cdf0e10cSrcweir return evoab::getFieldType (nField);
83cdf0e10cSrcweir }
84cdf0e10cSrcweir // -------------------------------------------------------------------------
getColumnCount()85cdf0e10cSrcweir sal_Int32 SAL_CALL OEvoabResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException)
86cdf0e10cSrcweir {
87cdf0e10cSrcweir return m_aEvoabFields.size();
88cdf0e10cSrcweir }
89cdf0e10cSrcweir // -------------------------------------------------------------------------
isCaseSensitive(sal_Int32)90cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSetMetaData::isCaseSensitive( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
91cdf0e10cSrcweir {
92cdf0e10cSrcweir return sal_True;
93cdf0e10cSrcweir }
94cdf0e10cSrcweir // -------------------------------------------------------------------------
getSchemaName(sal_Int32)95cdf0e10cSrcweir ::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getSchemaName( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
96cdf0e10cSrcweir {
97cdf0e10cSrcweir return ::rtl::OUString();
98cdf0e10cSrcweir }
99cdf0e10cSrcweir // -------------------------------------------------------------------------
getColumnName(sal_Int32 nColumnNum)100cdf0e10cSrcweir ::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getColumnName( sal_Int32 nColumnNum ) throw(SQLException, RuntimeException)
101cdf0e10cSrcweir {
102cdf0e10cSrcweir sal_uInt32 nField = m_aEvoabFields[nColumnNum - 1];
103cdf0e10cSrcweir return evoab::getFieldName( nField );
104cdf0e10cSrcweir }
105cdf0e10cSrcweir // -------------------------------------------------------------------------
getColumnTypeName(sal_Int32 nColumnNum)106cdf0e10cSrcweir ::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getColumnTypeName( sal_Int32 nColumnNum ) throw(SQLException, RuntimeException)
107cdf0e10cSrcweir {
108cdf0e10cSrcweir sal_uInt32 nField = m_aEvoabFields[nColumnNum - 1];
109cdf0e10cSrcweir return evoab::getFieldTypeName( nField );
110cdf0e10cSrcweir }
111cdf0e10cSrcweir // -------------------------------------------------------------------------
getColumnLabel(sal_Int32 nColumnNum)112cdf0e10cSrcweir ::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getColumnLabel( sal_Int32 nColumnNum ) throw(SQLException, RuntimeException)
113cdf0e10cSrcweir {
114cdf0e10cSrcweir sal_uInt32 nField = m_aEvoabFields[nColumnNum - 1];
115cdf0e10cSrcweir const ColumnProperty *pSpecs = getField(nField);
116cdf0e10cSrcweir GParamSpec *pSpec = pSpecs->pField;
117cdf0e10cSrcweir rtl::OUString aLabel;
118cdf0e10cSrcweir
119cdf0e10cSrcweir if( pSpec )
120cdf0e10cSrcweir aLabel = rtl::OStringToOUString( g_param_spec_get_nick( (GParamSpec *) pSpec ),
121cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 );
122cdf0e10cSrcweir return aLabel;
123cdf0e10cSrcweir }
124cdf0e10cSrcweir // -------------------------------------------------------------------------
getColumnServiceName(sal_Int32)125cdf0e10cSrcweir ::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getColumnServiceName( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
126cdf0e10cSrcweir {
127cdf0e10cSrcweir return ::rtl::OUString();
128cdf0e10cSrcweir }
129cdf0e10cSrcweir // -------------------------------------------------------------------------
getTableName(sal_Int32)130cdf0e10cSrcweir ::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getTableName( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
131cdf0e10cSrcweir {
132cdf0e10cSrcweir return m_aTableName;//::rtl::OUString::createFromAscii("TABLE");
133cdf0e10cSrcweir }
134cdf0e10cSrcweir // -------------------------------------------------------------------------
getCatalogName(sal_Int32)135cdf0e10cSrcweir ::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getCatalogName( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
136cdf0e10cSrcweir {
137cdf0e10cSrcweir return ::rtl::OUString();
138cdf0e10cSrcweir }
139cdf0e10cSrcweir // -------------------------------------------------------------------------
140cdf0e10cSrcweir
isCurrency(sal_Int32)141cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSetMetaData::isCurrency( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
142cdf0e10cSrcweir {
143cdf0e10cSrcweir return sal_False;
144cdf0e10cSrcweir }
145cdf0e10cSrcweir // -------------------------------------------------------------------------
isAutoIncrement(sal_Int32)146cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSetMetaData::isAutoIncrement( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
147cdf0e10cSrcweir {
148cdf0e10cSrcweir return sal_False;
149cdf0e10cSrcweir }
150cdf0e10cSrcweir // -------------------------------------------------------------------------
isSigned(sal_Int32)151cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSetMetaData::isSigned( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
152cdf0e10cSrcweir {
153cdf0e10cSrcweir return sal_False;
154cdf0e10cSrcweir }
155cdf0e10cSrcweir // -------------------------------------------------------------------------
getPrecision(sal_Int32)156cdf0e10cSrcweir sal_Int32 SAL_CALL OEvoabResultSetMetaData::getPrecision( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
157cdf0e10cSrcweir {
158cdf0e10cSrcweir return 0;
159cdf0e10cSrcweir }
160cdf0e10cSrcweir // -----------------------------------------------------------------------------
getScale(sal_Int32)161cdf0e10cSrcweir sal_Int32 SAL_CALL OEvoabResultSetMetaData::getScale( sal_Int32 /*nColumnNum*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
162cdf0e10cSrcweir {
163cdf0e10cSrcweir return 0;
164cdf0e10cSrcweir }
165cdf0e10cSrcweir // -------------------------------------------------------------------------
isNullable(sal_Int32)166cdf0e10cSrcweir sal_Int32 SAL_CALL OEvoabResultSetMetaData::isNullable( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
167cdf0e10cSrcweir {
168cdf0e10cSrcweir return 0;
169cdf0e10cSrcweir }
170cdf0e10cSrcweir // -------------------------------------------------------------------------
isSearchable(sal_Int32)171cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSetMetaData::isSearchable( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
172cdf0e10cSrcweir {
173cdf0e10cSrcweir return sal_True;
174cdf0e10cSrcweir }
175cdf0e10cSrcweir // -------------------------------------------------------------------------
isReadOnly(sal_Int32)176cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSetMetaData::isReadOnly( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
177cdf0e10cSrcweir {
178cdf0e10cSrcweir return sal_True;
179cdf0e10cSrcweir }
180cdf0e10cSrcweir // -------------------------------------------------------------------------
isDefinitelyWritable(sal_Int32)181cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSetMetaData::isDefinitelyWritable( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
182cdf0e10cSrcweir {
183cdf0e10cSrcweir return sal_False;
184cdf0e10cSrcweir }
185cdf0e10cSrcweir // -------------------------------------------------------------------------
isWritable(sal_Int32)186cdf0e10cSrcweir sal_Bool SAL_CALL OEvoabResultSetMetaData::isWritable( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
187cdf0e10cSrcweir {
188cdf0e10cSrcweir return sal_False;
189cdf0e10cSrcweir }
190cdf0e10cSrcweir // -------------------------------------------------------------------------
191