Files
libreoffice/connectivity/source/drivers/file/FResultSetMetaData.cxx

228 lines
9.4 KiB
C++
Raw Normal View History

2000-09-18 15:18:56 +00:00
/*************************************************************************
*
* $RCSfile: FResultSetMetaData.cxx,v $
*
2001-04-12 14:08:51 +00:00
* $Revision: 1.9 $
2000-09-18 15:18:56 +00:00
*
2001-04-12 14:08:51 +00:00
* last change: $Author: fs $ $Date: 2001-04-12 15:08:43 $
2000-09-18 15:18:56 +00:00
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (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.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _CONNECTIVITY_FILE_ORESULTSETMETADATA_HXX_
#include "file/FResultSetMetaData.hxx"
#endif
2000-10-24 15:19:10 +00:00
#define CONNECTIVITY_PROPERTY_NAME_SPACE file
2000-09-18 15:18:56 +00:00
#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_
#include "propertyids.hxx"
#endif
2000-09-29 14:30:09 +00:00
#ifndef _CONNECTIVITY_FILE_TABLE_HXX_
#include "file/FTable.hxx"
#endif
#ifndef _COMPHELPER_EXTRACT_HXX_
#include <comphelper/extract.hxx>
#endif
2000-09-18 15:18:56 +00:00
using namespace connectivity;
using namespace connectivity::file;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::lang;
2001-04-12 14:08:51 +00:00
// -------------------------------------------------------------------------
OResultSetMetaData::OResultSetMetaData(const ::vos::ORef<connectivity::OSQLColumns>& _rxColumns,const ::rtl::OUString& _aTableName,OFileTable* _pTable)
: m_xColumns(_rxColumns)
, m_aTableName(_aTableName)
, m_pTable(_pTable)
{
}
2000-09-18 15:18:56 +00:00
// -------------------------------------------------------------------------
OResultSetMetaData::~OResultSetMetaData()
{
}
2001-04-12 14:08:51 +00:00
2000-09-18 15:18:56 +00:00
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException)
{
2000-11-20 08:57:42 +00:00
return getINT32((*m_xColumns)[column-1]->getPropertyValue(PROPERTY_PRECISION));
2000-09-18 15:18:56 +00:00
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException)
{
2000-11-20 08:57:42 +00:00
return getINT32((*m_xColumns)[column-1]->getPropertyValue(PROPERTY_TYPE));
2000-09-18 15:18:56 +00:00
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException)
{
2000-11-20 08:57:42 +00:00
return (*m_xColumns).size();
2000-09-18 15:18:56 +00:00
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException)
{
2000-11-20 08:57:42 +00:00
return sal_False;
2000-09-18 15:18:56 +00:00
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 column ) throw(SQLException, RuntimeException)
{
return ::rtl::OUString();
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException)
{
2000-11-20 08:57:42 +00:00
Any aName((*m_xColumns)[column-1]->getPropertyValue(PROPERTY_REALNAME));
return aName.hasValue() ? getString(aName) : getString((*m_xColumns)[column-1]->getPropertyValue(PROPERTY_NAME));
2000-09-18 15:18:56 +00:00
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException)
{
return m_aTableName;
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 column ) throw(SQLException, RuntimeException)
{
return ::rtl::OUString();
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException)
{
2000-11-20 08:57:42 +00:00
return getString((*m_xColumns)[column-1]->getPropertyValue(PROPERTY_TYPENAME));
2000-09-18 15:18:56 +00:00
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException)
{
2000-11-20 08:57:42 +00:00
return getString((*m_xColumns)[column-1]->getPropertyValue(PROPERTY_NAME));
2000-09-18 15:18:56 +00:00
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(SQLException, RuntimeException)
{
return ::rtl::OUString();
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException)
{
2001-01-26 14:01:06 +00:00
return getBOOL((*m_xColumns)[column-1]->getPropertyValue(PROPERTY_ISCURRENCY));
2000-09-18 15:18:56 +00:00
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException)
{
2000-11-20 08:57:42 +00:00
return getBOOL((*m_xColumns)[column-1]->getPropertyValue(PROPERTY_ISAUTOINCREMENT));
2000-09-18 15:18:56 +00:00
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 column ) throw(SQLException, RuntimeException)
{
return sal_False;
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException)
{
2000-11-20 08:57:42 +00:00
return getINT32((*m_xColumns)[column-1]->getPropertyValue(PROPERTY_PRECISION));
2000-09-18 15:18:56 +00:00
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
2000-11-20 08:57:42 +00:00
return getINT32((*m_xColumns)[column-1]->getPropertyValue(PROPERTY_SCALE));
2000-09-18 15:18:56 +00:00
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException)
{
2000-11-20 08:57:42 +00:00
return getINT32((*m_xColumns)[column-1]->getPropertyValue(PROPERTY_ISNULLABLE));
2000-09-18 15:18:56 +00:00
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException)
{
return sal_True;
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException)
{
if((*m_xColumns)[column-1]->getPropertySetInfo()->hasPropertyByName(PROPERTY_FUNCTION) &&
::cppu::any2bool((*m_xColumns)[column-1]->getPropertyValue(PROPERTY_FUNCTION)))
return sal_True;
2000-09-29 14:30:09 +00:00
return m_pTable->isReadOnly();
2000-09-18 15:18:56 +00:00
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
{
if((*m_xColumns)[column-1]->getPropertySetInfo()->hasPropertyByName(PROPERTY_FUNCTION) &&
::cppu::any2bool((*m_xColumns)[column-1]->getPropertyValue(PROPERTY_FUNCTION)))
return sal_False;
2000-09-29 14:30:09 +00:00
return !m_pTable->isReadOnly();
2000-09-18 15:18:56 +00:00
;
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
{
if((*m_xColumns)[column-1]->getPropertySetInfo()->hasPropertyByName(PROPERTY_FUNCTION) &&
::cppu::any2bool((*m_xColumns)[column-1]->getPropertyValue(PROPERTY_FUNCTION)))
return sal_False;
2000-09-29 14:30:09 +00:00
return !m_pTable->isReadOnly();
2000-09-18 15:18:56 +00:00
}
// -------------------------------------------------------------------------