1*9b5730f6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9b5730f6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9b5730f6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9b5730f6SAndrew Rist * distributed with this work for additional information 6*9b5730f6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9b5730f6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9b5730f6SAndrew Rist * "License"); you may not use this file except in compliance 9*9b5730f6SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9b5730f6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9b5730f6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9b5730f6SAndrew Rist * software distributed under the License is distributed on an 15*9b5730f6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9b5730f6SAndrew Rist * KIND, either express or implied. See the License for the 17*9b5730f6SAndrew Rist * specific language governing permissions and limitations 18*9b5730f6SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9b5730f6SAndrew Rist *************************************************************/ 21*9b5730f6SAndrew Rist 22*9b5730f6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_connectivity.hxx" 26cdf0e10cSrcweir #include "ado/AKey.hxx" 27cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp> 28cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp> 29cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 30cdf0e10cSrcweir #include <comphelper/sequence.hxx> 31cdf0e10cSrcweir #include "ado/AColumns.hxx" 32cdf0e10cSrcweir #include "ado/AConnection.hxx" 33cdf0e10cSrcweir 34cdf0e10cSrcweir using namespace connectivity::ado; 35cdf0e10cSrcweir using namespace com::sun::star::uno; 36cdf0e10cSrcweir using namespace com::sun::star::lang; 37cdf0e10cSrcweir using namespace com::sun::star::beans; 38cdf0e10cSrcweir using namespace com::sun::star::sdbc; 39cdf0e10cSrcweir using namespace com::sun::star::sdbcx; 40cdf0e10cSrcweir 41cdf0e10cSrcweir // ------------------------------------------------------------------------- 42cdf0e10cSrcweir OAdoKey::OAdoKey(sal_Bool _bCase,OConnection* _pConnection, ADOKey* _pKey) 43cdf0e10cSrcweir : OKey_ADO(_bCase) 44cdf0e10cSrcweir ,m_pConnection(_pConnection) 45cdf0e10cSrcweir { 46cdf0e10cSrcweir construct(); 47cdf0e10cSrcweir m_aKey = WpADOKey(_pKey); 48cdf0e10cSrcweir fillPropertyValues(); 49cdf0e10cSrcweir } 50cdf0e10cSrcweir // ------------------------------------------------------------------------- 51cdf0e10cSrcweir OAdoKey::OAdoKey(sal_Bool _bCase,OConnection* _pConnection) 52cdf0e10cSrcweir : OKey_ADO(_bCase) 53cdf0e10cSrcweir ,m_pConnection(_pConnection) 54cdf0e10cSrcweir { 55cdf0e10cSrcweir construct(); 56cdf0e10cSrcweir m_aKey.Create(); 57cdf0e10cSrcweir } 58cdf0e10cSrcweir // ------------------------------------------------------------------------- 59cdf0e10cSrcweir void OAdoKey::refreshColumns() 60cdf0e10cSrcweir { 61cdf0e10cSrcweir TStringVector aVector; 62cdf0e10cSrcweir 63cdf0e10cSrcweir WpADOColumns aColumns; 64cdf0e10cSrcweir if ( m_aKey.IsValid() ) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir aColumns = m_aKey.get_Columns(); 67cdf0e10cSrcweir aColumns.fillElementNames(aVector); 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir if(m_pColumns) 71cdf0e10cSrcweir m_pColumns->reFill(aVector); 72cdf0e10cSrcweir else 73cdf0e10cSrcweir m_pColumns = new OColumns(*this,m_aMutex,aVector,aColumns,isCaseSensitive(),m_pConnection); 74cdf0e10cSrcweir } 75cdf0e10cSrcweir // ------------------------------------------------------------------------- 76cdf0e10cSrcweir Sequence< sal_Int8 > OAdoKey::getUnoTunnelImplementationId() 77cdf0e10cSrcweir { 78cdf0e10cSrcweir static ::cppu::OImplementationId * pId = 0; 79cdf0e10cSrcweir if (! pId) 80cdf0e10cSrcweir { 81cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); 82cdf0e10cSrcweir if (! pId) 83cdf0e10cSrcweir { 84cdf0e10cSrcweir static ::cppu::OImplementationId aId; 85cdf0e10cSrcweir pId = &aId; 86cdf0e10cSrcweir } 87cdf0e10cSrcweir } 88cdf0e10cSrcweir return pId->getImplementationId(); 89cdf0e10cSrcweir } 90cdf0e10cSrcweir 91cdf0e10cSrcweir // com::sun::star::lang::XUnoTunnel 92cdf0e10cSrcweir //------------------------------------------------------------------ 93cdf0e10cSrcweir sal_Int64 OAdoKey::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) 96cdf0e10cSrcweir ? reinterpret_cast< sal_Int64 >( this ) 97cdf0e10cSrcweir : OKey_ADO::getSomething(rId); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir // ------------------------------------------------------------------------- 100cdf0e10cSrcweir void OAdoKey::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir if(m_aKey.IsValid()) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir switch(nHandle) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir case PROPERTY_ID_NAME: 107cdf0e10cSrcweir { 108cdf0e10cSrcweir ::rtl::OUString aVal; 109cdf0e10cSrcweir rValue >>= aVal; 110cdf0e10cSrcweir m_aKey.put_Name(aVal); 111cdf0e10cSrcweir ADOS::ThrowException(*m_pConnection->getConnection(),*this); 112cdf0e10cSrcweir } 113cdf0e10cSrcweir break; 114cdf0e10cSrcweir case PROPERTY_ID_TYPE: 115cdf0e10cSrcweir { 116cdf0e10cSrcweir sal_Int32 nVal=0; 117cdf0e10cSrcweir rValue >>= nVal; 118cdf0e10cSrcweir m_aKey.put_Type(Map2KeyRule(nVal)); 119cdf0e10cSrcweir ADOS::ThrowException(*m_pConnection->getConnection(),*this); 120cdf0e10cSrcweir } 121cdf0e10cSrcweir break; 122cdf0e10cSrcweir case PROPERTY_ID_REFERENCEDTABLE: 123cdf0e10cSrcweir { 124cdf0e10cSrcweir ::rtl::OUString aVal; 125cdf0e10cSrcweir rValue >>= aVal; 126cdf0e10cSrcweir m_aKey.put_RelatedTable(aVal); 127cdf0e10cSrcweir ADOS::ThrowException(*m_pConnection->getConnection(),*this); 128cdf0e10cSrcweir } 129cdf0e10cSrcweir break; 130cdf0e10cSrcweir case PROPERTY_ID_UPDATERULE: 131cdf0e10cSrcweir { 132cdf0e10cSrcweir sal_Int32 nVal=0; 133cdf0e10cSrcweir rValue >>= nVal; 134cdf0e10cSrcweir m_aKey.put_UpdateRule(Map2Rule(nVal)); 135cdf0e10cSrcweir ADOS::ThrowException(*m_pConnection->getConnection(),*this); 136cdf0e10cSrcweir } 137cdf0e10cSrcweir break; 138cdf0e10cSrcweir case PROPERTY_ID_DELETERULE: 139cdf0e10cSrcweir { 140cdf0e10cSrcweir sal_Int32 nVal=0; 141cdf0e10cSrcweir rValue >>= nVal; 142cdf0e10cSrcweir m_aKey.put_DeleteRule(Map2Rule(nVal)); 143cdf0e10cSrcweir ADOS::ThrowException(*m_pConnection->getConnection(),*this); 144cdf0e10cSrcweir } 145cdf0e10cSrcweir break; 146cdf0e10cSrcweir } 147cdf0e10cSrcweir } 148cdf0e10cSrcweir OKey_ADO::setFastPropertyValue_NoBroadcast(nHandle,rValue); 149cdf0e10cSrcweir } 150cdf0e10cSrcweir // ------------------------------------------------------------------------- 151cdf0e10cSrcweir // ----------------------------------------------------------------------------- 152cdf0e10cSrcweir void SAL_CALL OAdoKey::acquire() throw() 153cdf0e10cSrcweir { 154cdf0e10cSrcweir OKey_ADO::acquire(); 155cdf0e10cSrcweir } 156cdf0e10cSrcweir // ----------------------------------------------------------------------------- 157cdf0e10cSrcweir void SAL_CALL OAdoKey::release() throw() 158cdf0e10cSrcweir { 159cdf0e10cSrcweir OKey_ADO::release(); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir // ----------------------------------------------------------------------------- 162cdf0e10cSrcweir 163cdf0e10cSrcweir 164