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