build fix
[LibreOffice.git] / connectivity / source / drivers / kab / KResultSetMetaData.cxx
blob35290e538d842b2857f5c81ef5b0dc8606283909
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 #include "KResultSetMetaData.hxx"
22 #include "kfields.hxx"
23 #include "KDatabaseMetaData.hxx"
24 #include <com/sun/star/sdbc/DataType.hpp>
26 using namespace connectivity::kab;
27 using namespace com::sun::star::uno;
28 using namespace com::sun::star::lang;
29 using namespace com::sun::star::sdbc;
31 KabResultSetMetaData::KabResultSetMetaData()
35 KabResultSetMetaData::~KabResultSetMetaData()
39 void KabResultSetMetaData::setKabFields(const ::rtl::Reference<connectivity::OSQLColumns> &xColumns) throw(SQLException)
41 OSQLColumns::Vector::const_iterator aIter;
42 static const char aName[] = "Name";
44 for (aIter = xColumns->get().begin(); aIter != xColumns->get().end(); ++aIter)
46 OUString aFieldName;
47 sal_uInt32 nFieldNumber;
49 (*aIter)->getPropertyValue(aName) >>= aFieldName;
50 nFieldNumber = findKabField(aFieldName);
51 m_aKabFields.push_back(nFieldNumber);
55 sal_Int32 SAL_CALL KabResultSetMetaData::getColumnDisplaySize(sal_Int32 column) throw(SQLException, RuntimeException, std::exception)
57 return m_aKabFields[column - 1] < KAB_DATA_FIELDS? 20: 50;
60 sal_Int32 SAL_CALL KabResultSetMetaData::getColumnType(sal_Int32 column) throw(SQLException, RuntimeException, std::exception)
62 return m_aKabFields[column - 1] == KAB_FIELD_REVISION? DataType::TIMESTAMP: DataType::CHAR;
65 sal_Int32 SAL_CALL KabResultSetMetaData::getColumnCount() throw(SQLException, RuntimeException, std::exception)
67 return m_aKabFields.size();
70 sal_Bool SAL_CALL KabResultSetMetaData::isCaseSensitive(sal_Int32) throw(SQLException, RuntimeException, std::exception)
72 return true;
75 OUString SAL_CALL KabResultSetMetaData::getSchemaName(sal_Int32) throw(SQLException, RuntimeException, std::exception)
77 return OUString();
80 OUString SAL_CALL KabResultSetMetaData::getColumnName(sal_Int32 column) throw(SQLException, RuntimeException, std::exception)
82 sal_uInt32 nFieldNumber = m_aKabFields[column - 1];
83 ::KABC::Field::List aFields = ::KABC::Field::allFields();
84 QString aQtName;
86 switch (nFieldNumber)
88 case KAB_FIELD_REVISION:
89 aQtName = KABC::Addressee::revisionLabel();
90 break;
91 default:
92 aQtName = aFields[nFieldNumber - KAB_DATA_FIELDS]->label();
94 OUString aName(reinterpret_cast<const sal_Unicode *>(aQtName.ucs2()));
96 return aName;
99 OUString SAL_CALL KabResultSetMetaData::getTableName(sal_Int32) throw(SQLException, RuntimeException, std::exception)
101 return KabDatabaseMetaData::getAddressBookTableName();
104 OUString SAL_CALL KabResultSetMetaData::getCatalogName(sal_Int32) throw(SQLException, RuntimeException, std::exception)
106 return OUString();
109 OUString SAL_CALL KabResultSetMetaData::getColumnTypeName(sal_Int32) throw(SQLException, RuntimeException, std::exception)
111 return OUString();
114 OUString SAL_CALL KabResultSetMetaData::getColumnLabel(sal_Int32) throw(SQLException, RuntimeException, std::exception)
116 return OUString();
119 OUString SAL_CALL KabResultSetMetaData::getColumnServiceName(sal_Int32) throw(SQLException, RuntimeException, std::exception)
121 return OUString();
124 sal_Bool SAL_CALL KabResultSetMetaData::isCurrency(sal_Int32) throw(SQLException, RuntimeException, std::exception)
126 return false;
129 sal_Bool SAL_CALL KabResultSetMetaData::isAutoIncrement(sal_Int32) throw(SQLException, RuntimeException, std::exception)
131 return false;
134 sal_Bool SAL_CALL KabResultSetMetaData::isSigned(sal_Int32) throw(SQLException, RuntimeException, std::exception)
136 return false;
139 sal_Int32 SAL_CALL KabResultSetMetaData::getPrecision(sal_Int32) throw(SQLException, RuntimeException, std::exception)
141 return 0;
144 sal_Int32 SAL_CALL KabResultSetMetaData::getScale(sal_Int32) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception)
146 return 0;
149 sal_Int32 SAL_CALL KabResultSetMetaData::isNullable(sal_Int32) throw(SQLException, RuntimeException, std::exception)
151 return (sal_Int32) true;
152 // KDE address book currently does not use nullptr values.
153 // But it might do it someday
156 sal_Bool SAL_CALL KabResultSetMetaData::isSearchable(sal_Int32) throw(SQLException, RuntimeException, std::exception)
158 return true;
161 sal_Bool SAL_CALL KabResultSetMetaData::isReadOnly(sal_Int32) throw(SQLException, RuntimeException, std::exception)
163 return true;
166 sal_Bool SAL_CALL KabResultSetMetaData::isDefinitelyWritable(sal_Int32) throw(SQLException, RuntimeException, std::exception)
168 return false;
171 sal_Bool SAL_CALL KabResultSetMetaData::isWritable(sal_Int32) throw(SQLException, RuntimeException, std::exception)
173 return false;
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */