1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_connectivity.hxx" 26 #include "ado/ATables.hxx" 27 #include "ado/ATable.hxx" 28 #include <com/sun/star/sdbc/XRow.hpp> 29 #include <com/sun/star/sdbc/XResultSet.hpp> 30 #include <com/sun/star/sdbc/ColumnValue.hpp> 31 #include <com/sun/star/sdbc/KeyRule.hpp> 32 #include <com/sun/star/sdbcx/KeyType.hpp> 33 #include "ado/ACatalog.hxx" 34 #include "ado/AConnection.hxx" 35 #include "ado/Awrapado.hxx" 36 #include "TConnection.hxx" 37 #include <comphelper/types.hxx> 38 #include <cppuhelper/interfacecontainer.h> 39 #include <connectivity/dbexception.hxx> 40 #include "resource/ado_res.hrc" 41 42 using namespace ::cppu; 43 using namespace connectivity; 44 using namespace comphelper; 45 using namespace connectivity::ado; 46 using namespace com::sun::star::uno; 47 using namespace com::sun::star::lang; 48 using namespace com::sun::star::beans; 49 using namespace com::sun::star::sdbc; 50 using namespace com::sun::star::container; 51 using namespace com::sun::star::lang; 52 53 typedef connectivity::sdbcx::OCollection OCollection_TYPE; 54 55 sdbcx::ObjectType OTables::createObject(const ::rtl::OUString& _rName) 56 { 57 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid"); 58 return new OAdoTable(this,isCaseSensitive(),m_pCatalog,m_aCollection.GetItem(_rName)); 59 } 60 // ------------------------------------------------------------------------- 61 void OTables::impl_refresh( ) throw(RuntimeException) 62 { 63 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid"); 64 m_aCollection.Refresh(); 65 m_pCatalog->refreshTables(); 66 } 67 // ------------------------------------------------------------------------- 68 Reference< XPropertySet > OTables::createDescriptor() 69 { 70 return new OAdoTable(this,isCaseSensitive(),m_pCatalog); 71 } 72 // ------------------------------------------------------------------------- 73 // XAppend 74 sdbcx::ObjectType OTables::appendObject( const ::rtl::OUString&, const Reference< XPropertySet >& descriptor ) 75 { 76 OAdoTable* pTable = NULL; 77 if ( !getImplementation( pTable, descriptor ) || pTable == NULL ) 78 m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_TABLE_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) ); 79 80 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid"); 81 if(!m_aCollection.Append(pTable->getImpl())) 82 ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this)); 83 m_aCollection.Refresh(); 84 85 return new OAdoTable(this,isCaseSensitive(),m_pCatalog,pTable->getImpl()); 86 } 87 // ------------------------------------------------------------------------- 88 // XDrop 89 void OTables::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName) 90 { 91 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid"); 92 if ( !m_aCollection.Delete(_sElementName) ) 93 ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this)); 94 } 95 // ----------------------------------------------------------------------------- 96 void OTables::appendNew(const ::rtl::OUString& _rsNewTable) 97 { 98 OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid"); 99 m_aCollection.Refresh(); 100 101 insertElement(_rsNewTable,NULL); 102 103 // notify our container listeners 104 ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_rsNewTable), Any(), Any()); 105 OInterfaceIteratorHelper aListenerLoop(m_aContainerListeners); 106 while (aListenerLoop.hasMoreElements()) 107 static_cast<XContainerListener*>(aListenerLoop.next())->elementInserted(aEvent); 108 } 109 // ----------------------------------------------------------------------------- 110 111 112