bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / mork / MResultSetMetaData.cxx
blobd7a82dd95034ff5a8c1bde335123785a576799f2
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 <connectivity/dbexception.hxx>
21 #include <connectivity/dbtools.hxx>
22 #include <comphelper/types.hxx>
23 #include <comphelper/extract.hxx>
24 #include <cppuhelper/typeprovider.hxx>
25 #include <tools/diagnose_ex.h>
26 #include "MResultSetMetaData.hxx"
27 #include <com/sun/star/sdbc/DataType.hpp>
29 using namespace connectivity::mork;
30 using namespace com::sun::star::uno;
31 using namespace com::sun::star::lang;
32 using namespace com::sun::star::sdbc;
33 using namespace com::sun::star::beans;
34 using namespace ::dbtools;
35 using namespace ::comphelper;
38 OResultSetMetaData::~OResultSetMetaData()
40 m_xColumns = nullptr;
44 void OResultSetMetaData::checkColumnIndex(sal_Int32 column)
46 if(column <= 0 || column > static_cast<sal_Int32>(m_xColumns->get().size()))
47 throwInvalidIndexException(*this);
50 sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column )
52 return getPrecision(column);
56 sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 /*column*/ )
58 return DataType::VARCHAR; // at the moment there exists only this type
62 sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( )
64 return static_cast<sal_Int32>(m_xColumns->get().size());
68 sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 /*column*/ )
70 return false;
74 OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 /*column*/ )
76 return OUString();
80 OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column )
82 checkColumnIndex(column);
84 OUString sColumnName;
85 try
87 Reference< XPropertySet > xColumnProps( (m_xColumns->get())[column-1], UNO_SET_THROW );
88 OSL_VERIFY( xColumnProps->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_NAME ) ) >>= sColumnName );
90 catch( const Exception& )
92 DBG_UNHANDLED_EXCEPTION("connectivity.mork");
94 return sColumnName;
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->get())[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->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)));
131 sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 /*column*/ )
133 return false;
136 sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 /*column*/ )
138 return false;
141 sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column )
143 checkColumnIndex(column);
144 return getINT32((m_xColumns->get())[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->get())[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->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)));
161 sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 /*column*/ )
163 if ( !m_pTable || !m_pTable->getConnection() )
165 OSL_FAIL( "OResultSetMetaData::isSearchable: suspicious: called without table or connection!" );
166 return false;
169 return true;
173 sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column )
175 checkColumnIndex(column);
176 bool bReadOnly = (m_xColumns->get())[column-1]->getPropertySetInfo()->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION)) &&
177 ::cppu::any2bool((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION)));
179 return m_bReadOnly || bReadOnly || OTable::isReadOnly();
183 sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column )
185 return !isReadOnly(column);
188 sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column )
190 return !isReadOnly(column);
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */