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/AIndexes.hxx" 27 #include "ado/AIndex.hxx" 28 #include "ado/AConnection.hxx" 29 #include <com/sun/star/sdbc/XRow.hpp> 30 #include <com/sun/star/sdbc/XResultSet.hpp> 31 #include <com/sun/star/sdbc/IndexType.hpp> 32 #include "TConnection.hxx" 33 #include <comphelper/types.hxx> 34 #include <connectivity/dbexception.hxx> 35 #include "resource/ado_res.hrc" 36 using namespace ::comphelper; 37 38 39 using namespace connectivity; 40 using namespace connectivity::ado; 41 using namespace com::sun::star::uno; 42 using namespace com::sun::star::lang; 43 using namespace com::sun::star::beans; 44 using namespace com::sun::star::sdbc; 45 using namespace com::sun::star::container; 46 47 sdbcx::ObjectType OIndexes::createObject(const ::rtl::OUString& _rName) 48 { 49 return new OAdoIndex(isCaseSensitive(),m_pConnection,m_aCollection.GetItem(_rName)); 50 } 51 // ------------------------------------------------------------------------- 52 void OIndexes::impl_refresh() throw(RuntimeException) 53 { 54 m_aCollection.Refresh(); 55 } 56 // ------------------------------------------------------------------------- 57 Reference< XPropertySet > OIndexes::createDescriptor() 58 { 59 return new OAdoIndex(isCaseSensitive(),m_pConnection); 60 } 61 // ------------------------------------------------------------------------- 62 // XAppend 63 sdbcx::ObjectType OIndexes::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor ) 64 { 65 OAdoIndex* pIndex = NULL; 66 if ( !getImplementation(pIndex,descriptor) || pIndex == NULL ) 67 m_pConnection->throwGenericSQLException( STR_INVALID_INDEX_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) ); 68 69 ADOIndexes* pIndexes = m_aCollection; 70 if ( FAILED( pIndexes->Append( OLEVariant( _rForName ), OLEVariant( pIndex->getImpl() ) ) ) ) 71 { 72 ADOS::ThrowException(*m_pConnection->getConnection(),static_cast<XTypeProvider*>(this)); 73 m_pConnection->throwGenericSQLException( STR_INVALID_INDEX_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) ); 74 } 75 76 return new OAdoIndex(isCaseSensitive(),m_pConnection,pIndex->getImpl()); 77 } 78 // ------------------------------------------------------------------------- 79 // XDrop 80 void OIndexes::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName) 81 { 82 m_aCollection.Delete(_sElementName); 83 } 84 // ----------------------------------------------------------------------------- 85 86 87