Files
libreoffice/connectivity/source/drivers/dbase/DTables.cxx

147 lines
5.5 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2000-09-18 15:18:56 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 15:18:56 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 15:18:56 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 15:18:56 +00:00
*
* This file is part of OpenOffice.org.
2000-09-18 15:18:56 +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.
2000-09-18 15:18:56 +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).
2000-09-18 15:18:56 +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.
2000-09-18 15:18:56 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_connectivity.hxx"
2000-09-18 15:18:56 +00:00
#include "dbase/DTables.hxx"
#include "dbase/DTable.hxx"
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <com/sun/star/sdbc/ColumnValue.hpp>
#include <com/sun/star/sdbc/KeyRule.hpp>
#include <com/sun/star/sdbcx/KeyType.hpp>
#include "file/FCatalog.hxx"
#include "file/FConnection.hxx"
#include <com/sun/star/lang/XUnoTunnel.hpp>
2000-10-30 07:07:33 +00:00
#include "dbase/DCatalog.hxx"
#include <comphelper/types.hxx>
2008-10-01 12:28:29 +00:00
#include "resource/dbase_res.hrc"
#include "connectivity/dbexception.hxx"
2001-05-18 07:51:34 +00:00
using namespace ::comphelper;
using namespace connectivity;
2000-09-18 15:18:56 +00:00
using namespace connectivity::dbase;
using namespace connectivity::file;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::container;
namespace starutil = ::com::sun::star::util;
sdbcx::ObjectType ODbaseTables::createObject(const ::rtl::OUString& _rName)
2000-09-18 15:18:56 +00:00
{
::rtl::OUString aName,aSchema;
ODbaseTable* pRet = new ODbaseTable(this,(ODbaseConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection(),
_rName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TABLE")));
2000-09-18 15:18:56 +00:00
sdbcx::ObjectType xRet = pRet;
2001-02-22 12:53:00 +00:00
pRet->construct();
2000-09-18 15:18:56 +00:00
return xRet;
}
// -------------------------------------------------------------------------
void ODbaseTables::impl_refresh( ) throw(RuntimeException)
{
2000-10-30 07:07:33 +00:00
static_cast<ODbaseCatalog*>(&m_rParent)->refreshTables();
2000-09-18 15:18:56 +00:00
}
// -------------------------------------------------------------------------
Reference< XPropertySet > ODbaseTables::createDescriptor()
2000-09-18 15:18:56 +00:00
{
2001-10-12 11:02:56 +00:00
return new ODbaseTable(this,(ODbaseConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection());
2000-09-18 15:18:56 +00:00
}
typedef connectivity::sdbcx::OCollection ODbaseTables_BASE_BASE;
// -------------------------------------------------------------------------
// XAppend
sdbcx::ObjectType ODbaseTables::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
2000-09-18 15:18:56 +00:00
{
Reference<XUnoTunnel> xTunnel(descriptor,UNO_QUERY);
if(xTunnel.is())
{
ODbaseTable* pTable = reinterpret_cast< ODbaseTable* >( xTunnel->getSomething(ODbaseTable::getUnoTunnelImplementationId()) );
2001-02-22 12:53:00 +00:00
if(pTable)
2000-11-03 13:21:22 +00:00
{
pTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(_rForName));
2001-09-18 12:14:31 +00:00
try
2001-05-30 09:44:16 +00:00
{
2001-10-12 11:02:56 +00:00
if(!pTable->CreateImpl())
throw SQLException();
2001-09-18 12:14:31 +00:00
}
catch(SQLException&)
{
throw;
}
catch(Exception&)
{
throw SQLException();
2001-05-30 09:44:16 +00:00
}
2000-11-03 13:21:22 +00:00
}
2000-09-18 15:18:56 +00:00
}
return createObject( _rForName );
2000-09-18 15:18:56 +00:00
}
// -------------------------------------------------------------------------
// XDrop
2001-10-12 11:02:56 +00:00
void ODbaseTables::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
2000-09-18 15:18:56 +00:00
{
Reference< XUnoTunnel> xTunnel;
try
{
xTunnel.set(getObject(_nPos),UNO_QUERY);
}
catch(const Exception&)
{
if(ODbaseTable::Drop_Static(ODbaseTable::getEntry(static_cast<OFileCatalog&>(m_rParent).getConnection(),_sElementName),sal_False,NULL))
return;
}
2001-03-28 10:32:43 +00:00
if ( xTunnel.is() )
2000-09-18 15:18:56 +00:00
{
ODbaseTable* pTable = reinterpret_cast< ODbaseTable* >( xTunnel->getSomething(ODbaseTable::getUnoTunnelImplementationId()) );
2001-10-12 11:02:56 +00:00
if(pTable)
pTable->DropImpl();
2000-09-18 15:18:56 +00:00
}
2001-03-28 10:32:43 +00:00
else
2008-10-01 12:28:29 +00:00
{
const ::rtl::OUString sError( static_cast<OFileCatalog&>(m_rParent).getConnection()->getResources().getResourceStringWithSubstitution(
STR_TABLE_NOT_DROP,
"$tablename$", _sElementName
) );
::dbtools::throwGenericSQLException( sError, NULL );
}
2000-09-18 15:18:56 +00:00
}
// -------------------------------------------------------------------------
2000-10-25 10:30:56 +00:00
Any SAL_CALL ODbaseTables::queryInterface( const Type & rType ) throw(RuntimeException)
{
typedef sdbcx::OCollection OTables_BASE;
return OTables_BASE::queryInterface(rType);
}
2001-10-12 11:02:56 +00:00
// -----------------------------------------------------------------------------
2000-09-18 15:18:56 +00:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */