update dev300-m58
[ooovba.git] / connectivity / source / drivers / ado / ATables.cxx
blob384607bdef1a10d22ee7da4a9eebfcd2c8f5b365
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ATables.cxx,v $
10 * $Revision: 1.21.56.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include "ado/ATables.hxx"
34 #include "ado/ATable.hxx"
35 #include <com/sun/star/sdbc/XRow.hpp>
36 #include <com/sun/star/sdbc/XResultSet.hpp>
37 #include <com/sun/star/sdbc/ColumnValue.hpp>
38 #include <com/sun/star/sdbc/KeyRule.hpp>
39 #include <com/sun/star/sdbcx/KeyType.hpp>
40 #include "ado/ACatalog.hxx"
41 #include "ado/AConnection.hxx"
42 #include "ado/Awrapado.hxx"
43 #include "TConnection.hxx"
44 #include <comphelper/types.hxx>
45 #include <cppuhelper/interfacecontainer.h>
46 #include <connectivity/dbexception.hxx>
47 #include "resource/ado_res.hrc"
49 using namespace ::cppu;
50 using namespace connectivity;
51 using namespace comphelper;
52 using namespace connectivity::ado;
53 using namespace com::sun::star::uno;
54 using namespace com::sun::star::lang;
55 using namespace com::sun::star::beans;
56 using namespace com::sun::star::sdbc;
57 using namespace com::sun::star::container;
58 using namespace com::sun::star::lang;
60 typedef connectivity::sdbcx::OCollection OCollection_TYPE;
62 sdbcx::ObjectType OTables::createObject(const ::rtl::OUString& _rName)
64 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
65 return new OAdoTable(this,isCaseSensitive(),m_pCatalog,m_aCollection.GetItem(_rName));
67 // -------------------------------------------------------------------------
68 void OTables::impl_refresh( ) throw(RuntimeException)
70 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
71 m_aCollection.Refresh();
72 m_pCatalog->refreshTables();
74 // -------------------------------------------------------------------------
75 Reference< XPropertySet > OTables::createDescriptor()
77 return new OAdoTable(this,isCaseSensitive(),m_pCatalog);
79 // -------------------------------------------------------------------------
80 // XAppend
81 sdbcx::ObjectType OTables::appendObject( const ::rtl::OUString&, const Reference< XPropertySet >& descriptor )
83 OAdoTable* pTable = NULL;
84 if ( !getImplementation( pTable, descriptor ) || pTable == NULL )
85 m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_TABLE_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) );
87 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
88 if(!m_aCollection.Append(pTable->getImpl()))
89 ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this));
90 m_aCollection.Refresh();
92 return new OAdoTable(this,isCaseSensitive(),m_pCatalog,pTable->getImpl());
94 // -------------------------------------------------------------------------
95 // XDrop
96 void OTables::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
98 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
99 if ( !m_aCollection.Delete(_sElementName) )
100 ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this));
102 // -----------------------------------------------------------------------------
103 void OTables::appendNew(const ::rtl::OUString& _rsNewTable)
105 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
106 m_aCollection.Refresh();
108 insertElement(_rsNewTable,NULL);
110 // notify our container listeners
111 ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_rsNewTable), Any(), Any());
112 OInterfaceIteratorHelper aListenerLoop(m_aContainerListeners);
113 while (aListenerLoop.hasMoreElements())
114 static_cast<XContainerListener*>(aListenerLoop.next())->elementInserted(aEvent);
116 // -----------------------------------------------------------------------------