2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2007-09-13 16:56:57 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 08:58:39 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2007-09-13 16:56:57 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2007-09-13 16:56:57 +00:00
|
|
|
*
|
2008-04-10 08:58:39 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2007-09-13 16:56:57 +00:00
|
|
|
*
|
2008-04-10 08:58:39 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2007-09-13 16:56:57 +00:00
|
|
|
*
|
2008-04-10 08:58:39 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2007-09-13 16:56:57 +00:00
|
|
|
*
|
2008-04-10 08:58:39 +00:00
|
|
|
* OpenOffice.org 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 version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2007-09-13 16:56:57 +00:00
|
|
|
*
|
2008-04-10 08:58:39 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2007-09-13 16:56:57 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_connectivity.hxx"
|
|
|
|
|
|
|
|
#include "MacabResultSetMetaData.hxx"
|
|
|
|
#include "MacabHeader.hxx"
|
|
|
|
#include "MacabRecords.hxx"
|
|
|
|
#include "MacabAddressBook.hxx"
|
|
|
|
#include "macabutilities.hxx"
|
2008-10-01 12:28:29 +00:00
|
|
|
#include "resource/macab_res.hrc"
|
2007-09-13 16:56:57 +00:00
|
|
|
|
|
|
|
using namespace connectivity::macab;
|
|
|
|
using namespace com::sun::star::uno;
|
|
|
|
using namespace com::sun::star::lang;
|
|
|
|
using namespace com::sun::star::sdbc;
|
|
|
|
|
|
|
|
MacabResultSetMetaData::MacabResultSetMetaData(MacabConnection* _pConnection, ::rtl::OUString _sTableName)
|
|
|
|
: m_pConnection(_pConnection),
|
|
|
|
m_sTableName(_sTableName),
|
|
|
|
m_aMacabFields()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
MacabResultSetMetaData::~MacabResultSetMetaData()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void MacabResultSetMetaData::setMacabFields(const ::vos::ORef<connectivity::OSQLColumns> &xColumns) throw(SQLException)
|
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
OSQLColumns::Vector::const_iterator aIter;
|
2007-09-13 16:56:57 +00:00
|
|
|
static const ::rtl::OUString aName(::rtl::OUString::createFromAscii("Name"));
|
|
|
|
MacabRecords *aRecords;
|
|
|
|
MacabHeader *aHeader;
|
|
|
|
|
|
|
|
aRecords = m_pConnection->getAddressBook()->getMacabRecords(m_sTableName);
|
|
|
|
|
|
|
|
// In case, somehow, we don't have anything with the name m_sTableName
|
|
|
|
if(aRecords == NULL)
|
|
|
|
{
|
2008-10-01 12:28:29 +00:00
|
|
|
impl_throwError(STR_NO_TABLE);
|
2007-09-13 16:56:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aHeader = aRecords->getHeader();
|
|
|
|
|
2008-12-30 13:32:01 +00:00
|
|
|
for (aIter = xColumns->get().begin(); aIter != xColumns->get().end(); ++aIter)
|
2007-09-13 16:56:57 +00:00
|
|
|
{
|
|
|
|
::rtl::OUString aFieldName;
|
|
|
|
sal_uInt32 nFieldNumber;
|
|
|
|
|
|
|
|
(*aIter)->getPropertyValue(aName) >>= aFieldName;
|
|
|
|
nFieldNumber = aHeader->getColumnNumber(aFieldName);
|
|
|
|
m_aMacabFields.push_back(nFieldNumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Int32 SAL_CALL MacabResultSetMetaData::getColumnDisplaySize(sal_Int32 column) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
// For now, all columns are the same size.
|
|
|
|
return 50;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Int32 SAL_CALL MacabResultSetMetaData::getColumnType(sal_Int32 column) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
MacabRecords *aRecords;
|
|
|
|
MacabHeader *aHeader;
|
|
|
|
macabfield *aField;
|
|
|
|
|
|
|
|
aRecords = m_pConnection->getAddressBook()->getMacabRecords(m_sTableName);
|
|
|
|
|
|
|
|
// In case, somehow, we don't have anything with the name m_sTableName
|
|
|
|
if(aRecords == NULL)
|
|
|
|
{
|
2008-10-01 12:28:29 +00:00
|
|
|
impl_throwError(STR_NO_TABLE);
|
2007-09-13 16:56:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aHeader = aRecords->getHeader();
|
|
|
|
aField = aHeader->get(column-1);
|
|
|
|
|
|
|
|
if(aField == NULL)
|
|
|
|
{
|
2008-10-01 12:28:29 +00:00
|
|
|
::dbtools::throwInvalidIndexException(*this,Any());
|
2007-09-13 16:56:57 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ABTypeToDataType(aField->type);
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Int32 SAL_CALL MacabResultSetMetaData::getColumnCount() throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
return m_aMacabFields.size();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Bool SAL_CALL MacabResultSetMetaData::isCaseSensitive(sal_Int32) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
::rtl::OUString SAL_CALL MacabResultSetMetaData::getSchemaName(sal_Int32) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
return ::rtl::OUString();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
::rtl::OUString SAL_CALL MacabResultSetMetaData::getColumnName(sal_Int32 column) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
sal_uInt32 nFieldNumber = m_aMacabFields[column - 1];
|
|
|
|
MacabRecords *aRecords;
|
|
|
|
MacabHeader *aHeader;
|
|
|
|
|
|
|
|
aRecords = m_pConnection->getAddressBook()->getMacabRecords(m_sTableName);
|
|
|
|
|
|
|
|
// In case, somehow, we don't have anything with the name m_sTableName
|
|
|
|
if(aRecords == NULL)
|
|
|
|
{
|
2008-10-01 12:28:29 +00:00
|
|
|
impl_throwError(STR_NO_TABLE);
|
2007-09-13 16:56:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aHeader = aRecords->getHeader();
|
|
|
|
::rtl::OUString aName = aHeader->getString(nFieldNumber);
|
|
|
|
|
|
|
|
return aName;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
::rtl::OUString SAL_CALL MacabResultSetMetaData::getTableName(sal_Int32) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
return m_sTableName;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
::rtl::OUString SAL_CALL MacabResultSetMetaData::getCatalogName(sal_Int32) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
return ::rtl::OUString();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
::rtl::OUString SAL_CALL MacabResultSetMetaData::getColumnTypeName(sal_Int32) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
return ::rtl::OUString();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
::rtl::OUString SAL_CALL MacabResultSetMetaData::getColumnLabel(sal_Int32) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
return ::rtl::OUString();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
::rtl::OUString SAL_CALL MacabResultSetMetaData::getColumnServiceName(sal_Int32) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
return ::rtl::OUString();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Bool SAL_CALL MacabResultSetMetaData::isCurrency(sal_Int32) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Bool SAL_CALL MacabResultSetMetaData::isAutoIncrement(sal_Int32) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Bool SAL_CALL MacabResultSetMetaData::isSigned(sal_Int32) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Int32 SAL_CALL MacabResultSetMetaData::getPrecision(sal_Int32) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Int32 SAL_CALL MacabResultSetMetaData::getScale(sal_Int32) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Int32 SAL_CALL MacabResultSetMetaData::isNullable(sal_Int32) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
return (sal_Int32) sal_True;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Bool SAL_CALL MacabResultSetMetaData::isSearchable(sal_Int32) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Bool SAL_CALL MacabResultSetMetaData::isReadOnly(sal_Int32) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Bool SAL_CALL MacabResultSetMetaData::isDefinitelyWritable(sal_Int32) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Bool SAL_CALL MacabResultSetMetaData::isWritable(sal_Int32) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2010-10-12 15:53:47 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|