update dev300-m58
[ooovba.git] / connectivity / source / drivers / kab / KResultSetMetaData.cxx
blob89175ade1a297b14835c49362748d6af4e88ed17
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: KResultSetMetaData.cxx,v $
10 * $Revision: 1.5 $
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 "KResultSetMetaData.hxx"
35 #include "kfields.hxx"
36 #include "KDatabaseMetaData.hxx"
37 #include <com/sun/star/sdbc/DataType.hpp>
39 using namespace connectivity::kab;
40 using namespace com::sun::star::uno;
41 using namespace com::sun::star::lang;
42 using namespace com::sun::star::sdbc;
44 KabResultSetMetaData::KabResultSetMetaData(KabConnection* _pConnection)
45 : m_pConnection(_pConnection),
46 m_aKabFields()
49 // -------------------------------------------------------------------------
50 KabResultSetMetaData::~KabResultSetMetaData()
53 // -------------------------------------------------------------------------
54 void KabResultSetMetaData::setKabFields(const ::vos::ORef<connectivity::OSQLColumns> &xColumns) throw(SQLException)
56 OSQLColumns::Vector::const_iterator aIter;
57 static const ::rtl::OUString aName(::rtl::OUString::createFromAscii("Name"));
59 for (aIter = xColumns->get().begin(); aIter != xColumns->get().end(); ++aIter)
61 ::rtl::OUString aFieldName;
62 sal_uInt32 nFieldNumber;
64 (*aIter)->getPropertyValue(aName) >>= aFieldName;
65 nFieldNumber = findKabField(aFieldName);
66 m_aKabFields.push_back(nFieldNumber);
69 // -------------------------------------------------------------------------
70 sal_Int32 SAL_CALL KabResultSetMetaData::getColumnDisplaySize(sal_Int32 column) throw(SQLException, RuntimeException)
72 return m_aKabFields[column - 1] < KAB_DATA_FIELDS? 20: 50;
74 // -------------------------------------------------------------------------
75 sal_Int32 SAL_CALL KabResultSetMetaData::getColumnType(sal_Int32 column) throw(SQLException, RuntimeException)
77 return m_aKabFields[column - 1] == KAB_FIELD_REVISION? DataType::TIMESTAMP: DataType::CHAR;
79 // -------------------------------------------------------------------------
80 sal_Int32 SAL_CALL KabResultSetMetaData::getColumnCount() throw(SQLException, RuntimeException)
82 return m_aKabFields.size();
84 // -------------------------------------------------------------------------
85 sal_Bool SAL_CALL KabResultSetMetaData::isCaseSensitive(sal_Int32) throw(SQLException, RuntimeException)
87 return sal_True;
89 // -------------------------------------------------------------------------
90 ::rtl::OUString SAL_CALL KabResultSetMetaData::getSchemaName(sal_Int32) throw(SQLException, RuntimeException)
92 return ::rtl::OUString();
94 // -------------------------------------------------------------------------
95 ::rtl::OUString SAL_CALL KabResultSetMetaData::getColumnName(sal_Int32 column) throw(SQLException, RuntimeException)
97 sal_uInt32 nFieldNumber = m_aKabFields[column - 1];
98 ::KABC::Field::List aFields = ::KABC::Field::allFields();
99 QString aQtName;
101 switch (nFieldNumber)
103 case KAB_FIELD_REVISION:
104 aQtName = KABC::Addressee::revisionLabel();
105 break;
106 default:
107 aQtName = aFields[nFieldNumber - KAB_DATA_FIELDS]->label();
109 ::rtl::OUString aName((const sal_Unicode *) aQtName.ucs2());
111 return aName;
113 // -------------------------------------------------------------------------
114 ::rtl::OUString SAL_CALL KabResultSetMetaData::getTableName(sal_Int32) throw(SQLException, RuntimeException)
116 return KabDatabaseMetaData::getAddressBookTableName();
118 // -------------------------------------------------------------------------
119 ::rtl::OUString SAL_CALL KabResultSetMetaData::getCatalogName(sal_Int32) throw(SQLException, RuntimeException)
121 return ::rtl::OUString();
123 // -------------------------------------------------------------------------
124 ::rtl::OUString SAL_CALL KabResultSetMetaData::getColumnTypeName(sal_Int32) throw(SQLException, RuntimeException)
126 return ::rtl::OUString();
128 // -------------------------------------------------------------------------
129 ::rtl::OUString SAL_CALL KabResultSetMetaData::getColumnLabel(sal_Int32) throw(SQLException, RuntimeException)
131 return ::rtl::OUString();
133 // -------------------------------------------------------------------------
134 ::rtl::OUString SAL_CALL KabResultSetMetaData::getColumnServiceName(sal_Int32) throw(SQLException, RuntimeException)
136 return ::rtl::OUString();
138 // -------------------------------------------------------------------------
139 sal_Bool SAL_CALL KabResultSetMetaData::isCurrency(sal_Int32) throw(SQLException, RuntimeException)
141 return sal_False;
143 // -------------------------------------------------------------------------
144 sal_Bool SAL_CALL KabResultSetMetaData::isAutoIncrement(sal_Int32) throw(SQLException, RuntimeException)
146 return sal_False;
148 // -------------------------------------------------------------------------
149 sal_Bool SAL_CALL KabResultSetMetaData::isSigned(sal_Int32) throw(SQLException, RuntimeException)
151 return sal_False;
153 // -------------------------------------------------------------------------
154 sal_Int32 SAL_CALL KabResultSetMetaData::getPrecision(sal_Int32) throw(SQLException, RuntimeException)
156 return 0;
158 // -----------------------------------------------------------------------------
159 sal_Int32 SAL_CALL KabResultSetMetaData::getScale(sal_Int32) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
161 return 0;
163 // -------------------------------------------------------------------------
164 sal_Int32 SAL_CALL KabResultSetMetaData::isNullable(sal_Int32) throw(SQLException, RuntimeException)
166 return (sal_Int32) sal_True;
167 // KDE address book currently does not use NULL values.
168 // But it might do it someday
170 // -------------------------------------------------------------------------
171 sal_Bool SAL_CALL KabResultSetMetaData::isSearchable(sal_Int32) throw(SQLException, RuntimeException)
173 return sal_True;
175 // -------------------------------------------------------------------------
176 sal_Bool SAL_CALL KabResultSetMetaData::isReadOnly(sal_Int32) throw(SQLException, RuntimeException)
178 return sal_True;
180 // -------------------------------------------------------------------------
181 sal_Bool SAL_CALL KabResultSetMetaData::isDefinitelyWritable(sal_Int32) throw(SQLException, RuntimeException)
183 return sal_False;
185 // -------------------------------------------------------------------------
186 sal_Bool SAL_CALL KabResultSetMetaData::isWritable(sal_Int32) throw(SQLException, RuntimeException)
188 return sal_False;
190 // -------------------------------------------------------------------------