nss: upgrade to release 3.73
[LibreOffice.git] / connectivity / source / drivers / file / FResultSetMetaData.cxx
blobf68a06532bb70f56bbc6ab210c7f8174846c9769
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 .
20 #include <file/FResultSetMetaData.hxx>
21 #include <file/FTable.hxx>
22 #include <comphelper/extract.hxx>
23 #include <connectivity/dbexception.hxx>
24 #include <comphelper/types.hxx>
27 using namespace ::comphelper;
28 using namespace connectivity;
29 using namespace dbtools;
30 using namespace connectivity::file;
31 using namespace ::com::sun::star::beans;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::sdbcx;
34 using namespace ::com::sun::star::sdbc;
35 using namespace ::com::sun::star::container;
36 using namespace ::com::sun::star::lang;
39 OResultSetMetaData::OResultSetMetaData(const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns,const OUString& _aTableName,OFileTable* _pTable)
40 :m_aTableName(_aTableName)
41 ,m_xColumns(_rxColumns)
42 ,m_pTable(_pTable)
47 OResultSetMetaData::~OResultSetMetaData()
49 m_xColumns = nullptr;
52 void OResultSetMetaData::checkColumnIndex(sal_Int32 column)
54 if(column <= 0 || column > static_cast<sal_Int32>(m_xColumns->size()))
55 throwInvalidIndexException(*this);
58 sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column )
60 return getPrecision(column);
64 sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 column )
66 checkColumnIndex(column);
67 return getINT32((*m_xColumns)[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)));
71 sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( )
73 return m_xColumns->size();
77 sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 /*column*/ )
79 return false;
83 OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 /*column*/ )
85 return OUString();
89 OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column )
91 checkColumnIndex(column);
93 Any aName((*m_xColumns)[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)));
94 return aName.hasValue() ? getString(aName) : getString((*m_xColumns)[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)));
97 OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 /*column*/ )
99 return m_aTableName;
102 OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 /*column*/ )
104 return OUString();
107 OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column )
109 checkColumnIndex(column);
110 return getString((*m_xColumns)[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)));
113 OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column )
115 return getColumnName(column);
118 OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 /*column*/ )
120 return OUString();
124 sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column )
126 checkColumnIndex(column);
127 return getBOOL((*m_xColumns)[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)));
131 sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 /*setCatalogcolumn*/ )
133 return false;
136 sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 /*column*/ )
138 return true;
141 sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column )
143 checkColumnIndex(column);
144 return getINT32((*m_xColumns)[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)));
147 sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column )
149 checkColumnIndex(column);
150 return getINT32((*m_xColumns)[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)));
154 sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column )
156 checkColumnIndex(column);
157 return getINT32((*m_xColumns)[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)));
161 sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 /*column*/ )
163 return true;
167 sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column )
169 checkColumnIndex(column);
170 return m_pTable->isReadOnly() || (
171 (*m_xColumns)[column-1]->getPropertySetInfo()->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION)) &&
172 ::cppu::any2bool((*m_xColumns)[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION))));
176 sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column )
178 return !isReadOnly(column);
181 sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column )
183 return !isReadOnly(column);
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */