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