2012-09-17 22:50:49 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
|
|
|
|
2014-06-04 15:29:58 +02:00
|
|
|
#include <connectivity/dbexception.hxx>
|
|
|
|
#include <connectivity/dbtools.hxx>
|
2012-09-17 22:50:49 +02:00
|
|
|
#include <comphelper/types.hxx>
|
|
|
|
#include <comphelper/extract.hxx>
|
|
|
|
#include <cppuhelper/typeprovider.hxx>
|
|
|
|
#include <tools/diagnose_ex.h>
|
|
|
|
#include "MResultSetMetaData.hxx"
|
|
|
|
#include <com/sun/star/sdbc/DataType.hpp>
|
|
|
|
|
|
|
|
using namespace connectivity::mork;
|
|
|
|
using namespace com::sun::star::uno;
|
|
|
|
using namespace com::sun::star::lang;
|
|
|
|
using namespace com::sun::star::sdbc;
|
|
|
|
using namespace com::sun::star::beans;
|
|
|
|
using namespace ::dbtools;
|
|
|
|
using namespace ::comphelper;
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-09-17 22:50:49 +02:00
|
|
|
OResultSetMetaData::~OResultSetMetaData()
|
|
|
|
{
|
2015-11-10 10:12:07 +01:00
|
|
|
m_xColumns = nullptr;
|
2012-09-17 22:50:49 +02:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-09-17 22:50:49 +02:00
|
|
|
void OResultSetMetaData::checkColumnIndex(sal_Int32 column) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
if(column <= 0 || column > (sal_Int32)(sal_Int32)m_xColumns->get().size())
|
|
|
|
throwInvalidIndexException(*this);
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
|
|
|
return getPrecision(column);
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-09-17 22:50:49 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
|
|
|
return DataType::VARCHAR; // at the moment there exists only this type
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-09-17 22:50:49 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
|
|
|
return static_cast<sal_Int32>((m_xColumns->get()).size());
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-09-17 22:50:49 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-09-17 22:50:49 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
return OUString();
|
2012-09-17 22:50:49 +02:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-09-17 22:50:49 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
|
|
|
checkColumnIndex(column);
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sColumnName;
|
2012-09-17 22:50:49 +02:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XPropertySet > xColumnProps( (m_xColumns->get())[column-1], UNO_QUERY_THROW );
|
|
|
|
OSL_VERIFY( xColumnProps->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_NAME ) ) >>= sColumnName );
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
|
|
|
}
|
|
|
|
return sColumnName;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
|
|
|
return m_aTableName;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
return OUString();
|
2012-09-17 22:50:49 +02:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
|
|
|
checkColumnIndex(column);
|
|
|
|
return getString((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)));
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
|
|
|
return getColumnName(column);
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
return OUString();
|
2012-09-17 22:50:49 +02:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-09-17 22:50:49 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
|
|
|
checkColumnIndex(column);
|
|
|
|
return getBOOL((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)));
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-09-17 22:50:49 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
|
|
|
checkColumnIndex(column);
|
|
|
|
return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)));
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
|
|
|
checkColumnIndex(column);
|
|
|
|
return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)));
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-09-17 22:50:49 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
|
|
|
checkColumnIndex(column);
|
|
|
|
return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)));
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-09-17 22:50:49 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
|
|
|
if ( !m_pTable || !m_pTable->getConnection() )
|
|
|
|
{
|
|
|
|
OSL_FAIL( "OResultSetMetaData::isSearchable: suspicious: called without table or connection!" );
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sal_True;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-09-17 22:50:49 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
|
|
|
checkColumnIndex(column);
|
2014-04-16 09:14:24 +02:00
|
|
|
bool bReadOnly = (m_xColumns->get())[column-1]->getPropertySetInfo()->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION)) &&
|
2012-09-17 22:50:49 +02:00
|
|
|
::cppu::any2bool((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION)));
|
|
|
|
|
2015-03-24 15:26:35 +02:00
|
|
|
return m_bReadOnly || bReadOnly || OTable::isReadOnly();
|
2012-09-17 22:50:49 +02:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-09-17 22:50:49 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
|
|
|
return !isReadOnly(column);
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException, std::exception)
|
2012-09-17 22:50:49 +02:00
|
|
|
{
|
|
|
|
return !isReadOnly(column);
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-09-17 22:50:49 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|