1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_connectivity.hxx" 30 #include "NResultSetMetaData.hxx" 31 #include "NDatabaseMetaData.hxx" 32 #include "connectivity/dbexception.hxx" 33 #include <com/sun/star/sdbc/DataType.hpp> 34 #include "NDebug.hxx" 35 #include "resource/evoab2_res.hrc" 36 37 using namespace connectivity::evoab; 38 using namespace com::sun::star::uno; 39 using namespace com::sun::star::lang; 40 using namespace com::sun::star::sdbc; 41 42 OEvoabResultSetMetaData::OEvoabResultSetMetaData(const ::rtl::OUString& _aTableName) 43 : m_aTableName(_aTableName), 44 m_aEvoabFields() 45 { 46 47 } 48 // ------------------------------------------------------------------------- 49 OEvoabResultSetMetaData::~OEvoabResultSetMetaData() 50 { 51 } 52 // ------------------------------------------------------------------------- 53 void OEvoabResultSetMetaData::setEvoabFields(const ::vos::ORef<connectivity::OSQLColumns> &xColumns) throw(SQLException) 54 { 55 OSQLColumns::Vector::const_iterator aIter; 56 static const ::rtl::OUString aName(::rtl::OUString::createFromAscii("Name")); 57 58 for (aIter = xColumns->get().begin(); aIter != xColumns->get().end(); ++aIter) 59 { 60 ::rtl::OUString aFieldName; 61 62 (*aIter)->getPropertyValue(aName) >>= aFieldName; 63 guint nFieldNumber = findEvoabField(aFieldName); 64 if (nFieldNumber == (guint)-1) 65 { 66 connectivity::SharedResources aResource; 67 const ::rtl::OUString sError( aResource.getResourceStringWithSubstitution( 68 STR_INVALID_COLUMNNAME, 69 "$columnname$", aFieldName 70 ) ); 71 ::dbtools::throwGenericSQLException( sError, *this ); 72 } 73 m_aEvoabFields.push_back(nFieldNumber); 74 } 75 } 76 77 // ------------------------------------------------------------------------- 78 sal_Int32 SAL_CALL OEvoabResultSetMetaData::getColumnDisplaySize( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 79 { 80 return 50; 81 } 82 // ------------------------------------------------------------------------- 83 sal_Int32 SAL_CALL OEvoabResultSetMetaData::getColumnType( sal_Int32 nColumnNum ) throw(SQLException, RuntimeException) 84 { 85 sal_uInt32 nField = m_aEvoabFields[nColumnNum - 1]; 86 return evoab::getFieldType (nField); 87 } 88 // ------------------------------------------------------------------------- 89 sal_Int32 SAL_CALL OEvoabResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException) 90 { 91 return m_aEvoabFields.size(); 92 } 93 // ------------------------------------------------------------------------- 94 sal_Bool SAL_CALL OEvoabResultSetMetaData::isCaseSensitive( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 95 { 96 return sal_True; 97 } 98 // ------------------------------------------------------------------------- 99 ::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getSchemaName( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 100 { 101 return ::rtl::OUString(); 102 } 103 // ------------------------------------------------------------------------- 104 ::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getColumnName( sal_Int32 nColumnNum ) throw(SQLException, RuntimeException) 105 { 106 sal_uInt32 nField = m_aEvoabFields[nColumnNum - 1]; 107 return evoab::getFieldName( nField ); 108 } 109 // ------------------------------------------------------------------------- 110 ::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getColumnTypeName( sal_Int32 nColumnNum ) throw(SQLException, RuntimeException) 111 { 112 sal_uInt32 nField = m_aEvoabFields[nColumnNum - 1]; 113 return evoab::getFieldTypeName( nField ); 114 } 115 // ------------------------------------------------------------------------- 116 ::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getColumnLabel( sal_Int32 nColumnNum ) throw(SQLException, RuntimeException) 117 { 118 sal_uInt32 nField = m_aEvoabFields[nColumnNum - 1]; 119 const ColumnProperty *pSpecs = getField(nField); 120 GParamSpec *pSpec = pSpecs->pField; 121 rtl::OUString aLabel; 122 123 if( pSpec ) 124 aLabel = rtl::OStringToOUString( g_param_spec_get_nick( (GParamSpec *) pSpec ), 125 RTL_TEXTENCODING_UTF8 ); 126 return aLabel; 127 } 128 // ------------------------------------------------------------------------- 129 ::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getColumnServiceName( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 130 { 131 return ::rtl::OUString(); 132 } 133 // ------------------------------------------------------------------------- 134 ::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getTableName( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 135 { 136 return m_aTableName;//::rtl::OUString::createFromAscii("TABLE"); 137 } 138 // ------------------------------------------------------------------------- 139 ::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getCatalogName( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 140 { 141 return ::rtl::OUString(); 142 } 143 // ------------------------------------------------------------------------- 144 145 sal_Bool SAL_CALL OEvoabResultSetMetaData::isCurrency( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 146 { 147 return sal_False; 148 } 149 // ------------------------------------------------------------------------- 150 sal_Bool SAL_CALL OEvoabResultSetMetaData::isAutoIncrement( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 151 { 152 return sal_False; 153 } 154 // ------------------------------------------------------------------------- 155 sal_Bool SAL_CALL OEvoabResultSetMetaData::isSigned( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 156 { 157 return sal_False; 158 } 159 // ------------------------------------------------------------------------- 160 sal_Int32 SAL_CALL OEvoabResultSetMetaData::getPrecision( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 161 { 162 return 0; 163 } 164 // ----------------------------------------------------------------------------- 165 sal_Int32 SAL_CALL OEvoabResultSetMetaData::getScale( sal_Int32 /*nColumnNum*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 166 { 167 return 0; 168 } 169 // ------------------------------------------------------------------------- 170 sal_Int32 SAL_CALL OEvoabResultSetMetaData::isNullable( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 171 { 172 return 0; 173 } 174 // ------------------------------------------------------------------------- 175 sal_Bool SAL_CALL OEvoabResultSetMetaData::isSearchable( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 176 { 177 return sal_True; 178 } 179 // ------------------------------------------------------------------------- 180 sal_Bool SAL_CALL OEvoabResultSetMetaData::isReadOnly( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 181 { 182 return sal_True; 183 } 184 // ------------------------------------------------------------------------- 185 sal_Bool SAL_CALL OEvoabResultSetMetaData::isDefinitelyWritable( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 186 { 187 return sal_False; 188 } 189 // ------------------------------------------------------------------------- 190 sal_Bool SAL_CALL OEvoabResultSetMetaData::isWritable( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) 191 { 192 return sal_False; 193 } 194 // ------------------------------------------------------------------------- 195