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 <com/sun/star/sdbc/DataType.hpp>
24 #include "resource/evoab2_res.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(const OUString
& _aTableName
)
32 : m_aTableName(_aTableName
),
38 OEvoabResultSetMetaData::~OEvoabResultSetMetaData()
42 void OEvoabResultSetMetaData::setEvoabFields(const ::rtl::Reference
<connectivity::OSQLColumns
> &xColumns
) throw(SQLException
)
44 OSQLColumns::Vector::const_iterator aIter
;
45 static const char aName
[] = "Name";
47 for (aIter
= xColumns
->get().begin(); aIter
!= xColumns
->get().end(); ++aIter
)
51 (*aIter
)->getPropertyValue(aName
) >>= aFieldName
;
52 guint nFieldNumber
= findEvoabField(aFieldName
);
53 if (nFieldNumber
== (guint
)-1)
55 connectivity::SharedResources aResource
;
56 const OUString
sError( aResource
.getResourceStringWithSubstitution(
57 STR_INVALID_COLUMNNAME
,
58 "$columnname$", aFieldName
60 ::dbtools::throwGenericSQLException( sError
, *this );
62 m_aEvoabFields
.push_back(nFieldNumber
);
67 sal_Int32 SAL_CALL
OEvoabResultSetMetaData::getColumnDisplaySize( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
, std::exception
)
72 sal_Int32 SAL_CALL
OEvoabResultSetMetaData::getColumnType( sal_Int32 nColumnNum
) throw(SQLException
, RuntimeException
, std::exception
)
74 sal_uInt32 nField
= m_aEvoabFields
[nColumnNum
- 1];
75 return evoab::getFieldType (nField
);
78 sal_Int32 SAL_CALL
OEvoabResultSetMetaData::getColumnCount( ) throw(SQLException
, RuntimeException
, std::exception
)
80 return m_aEvoabFields
.size();
83 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isCaseSensitive( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
, std::exception
)
88 OUString SAL_CALL
OEvoabResultSetMetaData::getSchemaName( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
, std::exception
)
93 OUString SAL_CALL
OEvoabResultSetMetaData::getColumnName( sal_Int32 nColumnNum
) throw(SQLException
, RuntimeException
, std::exception
)
95 sal_uInt32 nField
= m_aEvoabFields
[nColumnNum
- 1];
96 return evoab::getFieldName( nField
);
99 OUString SAL_CALL
OEvoabResultSetMetaData::getColumnTypeName( sal_Int32 nColumnNum
) throw(SQLException
, RuntimeException
, std::exception
)
101 sal_uInt32 nField
= m_aEvoabFields
[nColumnNum
- 1];
102 return evoab::getFieldTypeName( nField
);
105 OUString SAL_CALL
OEvoabResultSetMetaData::getColumnLabel( sal_Int32 nColumnNum
) throw(SQLException
, RuntimeException
, std::exception
)
107 sal_uInt32 nField
= m_aEvoabFields
[nColumnNum
- 1];
108 const ColumnProperty
*pSpecs
= getField(nField
);
109 GParamSpec
*pSpec
= pSpecs
->pField
;
113 aLabel
= OStringToOUString( g_param_spec_get_nick( pSpec
),
114 RTL_TEXTENCODING_UTF8
);
118 OUString SAL_CALL
OEvoabResultSetMetaData::getColumnServiceName( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
, std::exception
)
123 OUString SAL_CALL
OEvoabResultSetMetaData::getTableName( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
, std::exception
)
125 return m_aTableName
;//OUString("TABLE");
128 OUString SAL_CALL
OEvoabResultSetMetaData::getCatalogName( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
, std::exception
)
134 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isCurrency( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
, std::exception
)
139 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isAutoIncrement( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
, std::exception
)
144 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isSigned( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
, std::exception
)
149 sal_Int32 SAL_CALL
OEvoabResultSetMetaData::getPrecision( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
, std::exception
)
154 sal_Int32 SAL_CALL
OEvoabResultSetMetaData::getScale( sal_Int32
/*nColumnNum*/ ) throw(css::sdbc::SQLException
, css::uno::RuntimeException
, std::exception
)
159 sal_Int32 SAL_CALL
OEvoabResultSetMetaData::isNullable( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
, std::exception
)
164 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isSearchable( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
, std::exception
)
169 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isReadOnly( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
, std::exception
)
174 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isDefinitelyWritable( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
, std::exception
)
179 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isWritable( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
, std::exception
)
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */