2000-09-18 15:18:56 +00:00
/*************************************************************************
*
2005-09-08 04:40:33 +00:00
* OpenOffice . org - a multi - platform office productivity suite
2000-09-18 15:18:56 +00:00
*
2005-09-08 04:40:33 +00:00
* $ RCSfile : DTables . cxx , v $
2000-09-18 15:18:56 +00:00
*
2005-09-08 04:40:33 +00:00
* $ Revision : 1.23 $
2000-09-18 15:18:56 +00:00
*
2005-09-08 04:40:33 +00:00
* last change : $ Author : rt $ $ Date : 2005 - 09 - 08 05 : 40 : 33 $
2000-09-18 15:18:56 +00:00
*
2005-09-08 04:40:33 +00:00
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1 .
2000-09-18 15:18:56 +00:00
*
*
2005-09-08 04:40:33 +00:00
* GNU Lesser General Public License Version 2.1
* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* Copyright 2005 by Sun Microsystems , Inc .
* 901 San Antonio Road , Palo Alto , CA 94303 , USA
2000-09-18 15:18:56 +00:00
*
2005-09-08 04:40:33 +00:00
* 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 .
2000-09-18 15:18:56 +00:00
*
2005-09-08 04:40:33 +00:00
* 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 .
2000-09-18 15:18:56 +00:00
*
2005-09-08 04:40:33 +00:00
* 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
2000-09-18 15:18:56 +00:00
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# ifndef _CONNECTIVITY_DBASE_TABLES_HXX_
# include "dbase/DTables.hxx"
# endif
# ifndef _CONNECTIVITY_DBASE_TABLE_HXX_
# include "dbase/DTable.hxx"
# endif
# ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
# include <com/sun/star/sdbc/XRow.hpp>
# endif
# ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
# include <com/sun/star/sdbc/XResultSet.hpp>
# endif
# ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
# include <com/sun/star/sdbc/ColumnValue.hpp>
# endif
# ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_
# include <com/sun/star/sdbc/KeyRule.hpp>
# endif
# ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_
# include <com/sun/star/sdbcx/KeyType.hpp>
# endif
# ifndef _CONNECTIVITY_FILE_CATALOG_HXX_
# include "file/FCatalog.hxx"
# endif
# ifndef _CONNECTIVITY_FILE_BCONNECTION_HXX_
# include "file/FConnection.hxx"
# endif
# ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
# include <com/sun/star/lang/XUnoTunnel.hpp>
# endif
2000-10-30 07:07:33 +00:00
# ifndef _CONNECTIVITY_DBASE_CATALOG_HXX_
# include "dbase/DCatalog.hxx"
# endif
2000-12-08 11:55:13 +00:00
# ifndef _COMPHELPER_TYPES_HXX_
# include <comphelper/types.hxx>
# endif
2001-05-18 07:51:34 +00:00
using namespace : : comphelper ;
2005-03-10 14:25:55 +00:00
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 ;
2005-03-10 14:25:55 +00:00
sdbcx : : ObjectType ODbaseTables : : createObject ( const : : rtl : : OUString & _rName )
2000-09-18 15:18:56 +00:00
{
: : rtl : : OUString aName , aSchema ;
2001-09-25 12:12:51 +00:00
ODbaseTable * pRet = new ODbaseTable ( this , ( ODbaseConnection * ) static_cast < OFileCatalog & > ( m_rParent ) . getConnection ( ) ,
2000-09-18 15:18:56 +00:00
_rName , : : rtl : : OUString : : createFromAscii ( " TABLE " ) ) ;
2005-03-10 14:25:55 +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 : : createEmptyObject ( )
{
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
2001-10-12 11:02:56 +00:00
void ODbaseTables : : appendObject ( const Reference < XPropertySet > & descriptor )
2000-09-18 15:18:56 +00:00
{
Reference < XUnoTunnel > xTunnel ( descriptor , UNO_QUERY ) ;
if ( xTunnel . is ( ) )
{
ODbaseTable * pTable = ( ODbaseTable * ) xTunnel - > getSomething ( ODbaseTable : : getUnoTunnelImplementationId ( ) ) ;
2001-02-22 12:53:00 +00:00
if ( pTable )
2000-11-03 13:21:22 +00:00
{
2001-05-14 10:42:44 +00:00
pTable - > setPropertyValue ( OMetaConnection : : getPropMap ( ) . getNameByIndex ( PROPERTY_ID_NAME ) , descriptor - > getPropertyValue ( OMetaConnection : : getPropMap ( ) . getNameByIndex ( PROPERTY_ID_NAME ) ) ) ;
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
}
}
// -------------------------------------------------------------------------
// 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
{
2004-08-02 16:01:15 +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-08-10 10:05:34 +00:00
}
2001-03-28 10:32:43 +00:00
2004-08-02 16:01:15 +00:00
if ( xTunnel . is ( ) )
2000-09-18 15:18:56 +00:00
{
ODbaseTable * pTable = ( 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
2004-10-22 07:43:41 +00:00
throw SQLException ( : : rtl : : OUString : : createFromAscii ( " Can't drop table " ) + _sElementName , static_cast < XTypeProvider * > ( this ) , OMetaConnection : : getPropMap ( ) . getNameByIndex ( PROPERTY_ID_ERRORMSG_SEQUENCE ) , 1000 , Any ( ) ) ;
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