update dev300-m58
[ooovba.git] / connectivity / source / drivers / macab / MacabResultSetMetaData.cxx
blob60bdcdcc13d64d2cd0aa8a87d56fcb35904b1a23
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MacabResultSetMetaData.cxx,v $
10 * $Revision: 1.3.56.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
34 #include "MacabResultSetMetaData.hxx"
35 #include "MacabHeader.hxx"
36 #include "MacabRecords.hxx"
37 #include "MacabAddressBook.hxx"
38 #include "macabutilities.hxx"
39 #include "resource/macab_res.hrc"
41 using namespace connectivity::macab;
42 using namespace com::sun::star::uno;
43 using namespace com::sun::star::lang;
44 using namespace com::sun::star::sdbc;
46 MacabResultSetMetaData::MacabResultSetMetaData(MacabConnection* _pConnection, ::rtl::OUString _sTableName)
47 : m_pConnection(_pConnection),
48 m_sTableName(_sTableName),
49 m_aMacabFields()
52 // -------------------------------------------------------------------------
53 MacabResultSetMetaData::~MacabResultSetMetaData()
56 // -------------------------------------------------------------------------
57 void MacabResultSetMetaData::setMacabFields(const ::vos::ORef<connectivity::OSQLColumns> &xColumns) throw(SQLException)
59 OSQLColumns::Vector::const_iterator aIter;
60 static const ::rtl::OUString aName(::rtl::OUString::createFromAscii("Name"));
61 MacabRecords *aRecords;
62 MacabHeader *aHeader;
64 aRecords = m_pConnection->getAddressBook()->getMacabRecords(m_sTableName);
66 // In case, somehow, we don't have anything with the name m_sTableName
67 if(aRecords == NULL)
69 impl_throwError(STR_NO_TABLE);
72 aHeader = aRecords->getHeader();
74 for (aIter = xColumns->get().begin(); aIter != xColumns->get().end(); ++aIter)
76 ::rtl::OUString aFieldName;
77 sal_uInt32 nFieldNumber;
79 (*aIter)->getPropertyValue(aName) >>= aFieldName;
80 nFieldNumber = aHeader->getColumnNumber(aFieldName);
81 m_aMacabFields.push_back(nFieldNumber);
85 // -------------------------------------------------------------------------
86 sal_Int32 SAL_CALL MacabResultSetMetaData::getColumnDisplaySize(sal_Int32 column) throw(SQLException, RuntimeException)
88 // For now, all columns are the same size.
89 return 50;
91 // -------------------------------------------------------------------------
92 sal_Int32 SAL_CALL MacabResultSetMetaData::getColumnType(sal_Int32 column) throw(SQLException, RuntimeException)
94 MacabRecords *aRecords;
95 MacabHeader *aHeader;
96 macabfield *aField;
98 aRecords = m_pConnection->getAddressBook()->getMacabRecords(m_sTableName);
100 // In case, somehow, we don't have anything with the name m_sTableName
101 if(aRecords == NULL)
103 impl_throwError(STR_NO_TABLE);
106 aHeader = aRecords->getHeader();
107 aField = aHeader->get(column-1);
109 if(aField == NULL)
111 ::dbtools::throwInvalidIndexException(*this,Any());
112 return -1;
115 return ABTypeToDataType(aField->type);
117 // -------------------------------------------------------------------------
118 sal_Int32 SAL_CALL MacabResultSetMetaData::getColumnCount() throw(SQLException, RuntimeException)
120 return m_aMacabFields.size();
122 // -------------------------------------------------------------------------
123 sal_Bool SAL_CALL MacabResultSetMetaData::isCaseSensitive(sal_Int32) throw(SQLException, RuntimeException)
125 return sal_True;
127 // -------------------------------------------------------------------------
128 ::rtl::OUString SAL_CALL MacabResultSetMetaData::getSchemaName(sal_Int32) throw(SQLException, RuntimeException)
130 return ::rtl::OUString();
132 // -------------------------------------------------------------------------
133 ::rtl::OUString SAL_CALL MacabResultSetMetaData::getColumnName(sal_Int32 column) throw(SQLException, RuntimeException)
135 sal_uInt32 nFieldNumber = m_aMacabFields[column - 1];
136 MacabRecords *aRecords;
137 MacabHeader *aHeader;
139 aRecords = m_pConnection->getAddressBook()->getMacabRecords(m_sTableName);
141 // In case, somehow, we don't have anything with the name m_sTableName
142 if(aRecords == NULL)
144 impl_throwError(STR_NO_TABLE);
147 aHeader = aRecords->getHeader();
148 ::rtl::OUString aName = aHeader->getString(nFieldNumber);
150 return aName;
152 // -------------------------------------------------------------------------
153 ::rtl::OUString SAL_CALL MacabResultSetMetaData::getTableName(sal_Int32) throw(SQLException, RuntimeException)
155 return m_sTableName;
157 // -------------------------------------------------------------------------
158 ::rtl::OUString SAL_CALL MacabResultSetMetaData::getCatalogName(sal_Int32) throw(SQLException, RuntimeException)
160 return ::rtl::OUString();
162 // -------------------------------------------------------------------------
163 ::rtl::OUString SAL_CALL MacabResultSetMetaData::getColumnTypeName(sal_Int32) throw(SQLException, RuntimeException)
165 return ::rtl::OUString();
167 // -------------------------------------------------------------------------
168 ::rtl::OUString SAL_CALL MacabResultSetMetaData::getColumnLabel(sal_Int32) throw(SQLException, RuntimeException)
170 return ::rtl::OUString();
172 // -------------------------------------------------------------------------
173 ::rtl::OUString SAL_CALL MacabResultSetMetaData::getColumnServiceName(sal_Int32) throw(SQLException, RuntimeException)
175 return ::rtl::OUString();
177 // -------------------------------------------------------------------------
178 sal_Bool SAL_CALL MacabResultSetMetaData::isCurrency(sal_Int32) throw(SQLException, RuntimeException)
180 return sal_False;
182 // -------------------------------------------------------------------------
183 sal_Bool SAL_CALL MacabResultSetMetaData::isAutoIncrement(sal_Int32) throw(SQLException, RuntimeException)
185 return sal_False;
187 // -------------------------------------------------------------------------
188 sal_Bool SAL_CALL MacabResultSetMetaData::isSigned(sal_Int32) throw(SQLException, RuntimeException)
190 return sal_False;
192 // -------------------------------------------------------------------------
193 sal_Int32 SAL_CALL MacabResultSetMetaData::getPrecision(sal_Int32) throw(SQLException, RuntimeException)
195 return 0;
197 // -----------------------------------------------------------------------------
198 sal_Int32 SAL_CALL MacabResultSetMetaData::getScale(sal_Int32) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
200 return 0;
202 // -------------------------------------------------------------------------
203 sal_Int32 SAL_CALL MacabResultSetMetaData::isNullable(sal_Int32) throw(SQLException, RuntimeException)
205 return (sal_Int32) sal_True;
207 // -------------------------------------------------------------------------
208 sal_Bool SAL_CALL MacabResultSetMetaData::isSearchable(sal_Int32) throw(SQLException, RuntimeException)
210 return sal_True;
212 // -------------------------------------------------------------------------
213 sal_Bool SAL_CALL MacabResultSetMetaData::isReadOnly(sal_Int32) throw(SQLException, RuntimeException)
215 return sal_True;
217 // -------------------------------------------------------------------------
218 sal_Bool SAL_CALL MacabResultSetMetaData::isDefinitelyWritable(sal_Int32) throw(SQLException, RuntimeException)
220 return sal_False;
222 // -------------------------------------------------------------------------
223 sal_Bool SAL_CALL MacabResultSetMetaData::isWritable(sal_Int32) throw(SQLException, RuntimeException)
225 return sal_False;
227 // -------------------------------------------------------------------------