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