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/AIndex.hxx" 27 #include <com/sun/star/sdbc/XRow.hpp> 28 #include <com/sun/star/sdbc/XResultSet.hpp> 29 #include <cppuhelper/typeprovider.hxx> 30 #include <comphelper/sequence.hxx> 31 #include "ado/AColumns.hxx" 32 #include <comphelper/extract.hxx> 33 #include "TConnection.hxx" 34 #include <comphelper/types.hxx> 35 36 using namespace ::comphelper; 37 38 using namespace connectivity::ado; 39 using namespace com::sun::star::uno; 40 using namespace com::sun::star::lang; 41 using namespace com::sun::star::beans; 42 using namespace com::sun::star::sdbc; 43 44 // ------------------------------------------------------------------------- 45 OAdoIndex::OAdoIndex(sal_Bool _bCase,OConnection* _pConnection,ADOIndex* _pIndex) 46 : OIndex_ADO(::rtl::OUString(),::rtl::OUString(),sal_False,sal_False,sal_False,_bCase) 47 ,m_pConnection(_pConnection) 48 { 49 construct(); 50 m_aIndex = WpADOIndex(_pIndex); 51 fillPropertyValues(); 52 } 53 // ------------------------------------------------------------------------- 54 OAdoIndex::OAdoIndex(sal_Bool _bCase,OConnection* _pConnection) 55 : OIndex_ADO(_bCase) 56 ,m_pConnection(_pConnection) 57 { 58 construct(); 59 m_aIndex.Create(); 60 } 61 62 // ------------------------------------------------------------------------- 63 64 void OAdoIndex::refreshColumns() 65 { 66 TStringVector aVector; 67 68 WpADOColumns aColumns; 69 if ( m_aIndex.IsValid() ) 70 { 71 aColumns = m_aIndex.get_Columns(); 72 aColumns.fillElementNames(aVector); 73 } 74 75 if ( m_pColumns ) 76 m_pColumns->reFill(aVector); 77 else 78 m_pColumns = new OColumns(*this,m_aMutex,aVector,aColumns,isCaseSensitive(),m_pConnection); 79 } 80 81 // ------------------------------------------------------------------------- 82 Sequence< sal_Int8 > OAdoIndex::getUnoTunnelImplementationId() 83 { 84 static ::cppu::OImplementationId * pId = 0; 85 if (! pId) 86 { 87 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); 88 if (! pId) 89 { 90 static ::cppu::OImplementationId aId; 91 pId = &aId; 92 } 93 } 94 return pId->getImplementationId(); 95 } 96 97 // com::sun::star::lang::XUnoTunnel 98 //------------------------------------------------------------------ 99 sal_Int64 OAdoIndex::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) 100 { 101 return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) 102 ? reinterpret_cast< sal_Int64 >( this ) 103 : OIndex_ADO::getSomething(rId); 104 } 105 // ------------------------------------------------------------------------- 106 void SAL_CALL OAdoIndex::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception) 107 { 108 if(m_aIndex.IsValid()) 109 { 110 switch(nHandle) 111 { 112 case PROPERTY_ID_NAME: 113 { 114 ::rtl::OUString aVal; 115 rValue >>= aVal; 116 m_aIndex.put_Name(aVal); 117 } 118 break; 119 case PROPERTY_ID_CATALOG: 120 { 121 ::rtl::OUString aVal; 122 rValue >>= aVal; 123 m_aIndex.put_Name(aVal); 124 } 125 break; 126 case PROPERTY_ID_ISUNIQUE: 127 m_aIndex.put_Unique(getBOOL(rValue)); 128 break; 129 case PROPERTY_ID_ISPRIMARYKEYINDEX: 130 m_aIndex.put_PrimaryKey(getBOOL(rValue)); 131 break; 132 case PROPERTY_ID_ISCLUSTERED: 133 m_aIndex.put_Clustered(getBOOL(rValue)); 134 break; 135 } 136 } 137 OIndex_ADO::setFastPropertyValue_NoBroadcast(nHandle,rValue); 138 } 139 // ----------------------------------------------------------------------------- 140 void SAL_CALL OAdoIndex::acquire() throw() 141 { 142 OIndex_ADO::acquire(); 143 } 144 // ----------------------------------------------------------------------------- 145 void SAL_CALL OAdoIndex::release() throw() 146 { 147 OIndex_ADO::release(); 148 } 149 // ----------------------------------------------------------------------------- 150 151 152 153 154