1*96de5490SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*96de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*96de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*96de5490SAndrew Rist * distributed with this work for additional information 6*96de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*96de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*96de5490SAndrew Rist * "License"); you may not use this file except in compliance 9*96de5490SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*96de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*96de5490SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*96de5490SAndrew Rist * software distributed under the License is distributed on an 15*96de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*96de5490SAndrew Rist * KIND, either express or implied. See the License for the 17*96de5490SAndrew Rist * specific language governing permissions and limitations 18*96de5490SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*96de5490SAndrew Rist *************************************************************/ 21*96de5490SAndrew Rist 22*96de5490SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 26cdf0e10cSrcweir #ifndef DBA_HELPERCOLLECTIONS_HXX 27cdf0e10cSrcweir #include "HelperCollections.hxx" 28cdf0e10cSrcweir #endif 29cdf0e10cSrcweir 30cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBASTRINGS_HRC 31cdf0e10cSrcweir #include "dbastrings.hrc" 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir 34cdf0e10cSrcweir namespace dbaccess 35cdf0e10cSrcweir { 36cdf0e10cSrcweir using namespace dbtools; 37cdf0e10cSrcweir using namespace comphelper; 38cdf0e10cSrcweir using namespace connectivity; 39cdf0e10cSrcweir using namespace ::com::sun::star::uno; 40cdf0e10cSrcweir using namespace ::com::sun::star::beans; 41cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 42cdf0e10cSrcweir using namespace ::com::sun::star::sdb; 43cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx; 44cdf0e10cSrcweir using namespace ::com::sun::star::container; 45cdf0e10cSrcweir using namespace ::com::sun::star::lang; 46cdf0e10cSrcweir using namespace ::com::sun::star::script; 47cdf0e10cSrcweir using namespace ::cppu; 48cdf0e10cSrcweir using namespace ::osl; 49cdf0e10cSrcweir // ----------------------------------------------------------------------------- OPrivateColumns(const::vos::ORef<::connectivity::OSQLColumns> & _rColumns,sal_Bool _bCase,::cppu::OWeakObject & _rParent,::osl::Mutex & _rMutex,const::std::vector<::rtl::OUString> & _rVector,sal_Bool _bUseAsIndex)50cdf0e10cSrcweir OPrivateColumns::OPrivateColumns(const ::vos::ORef< ::connectivity::OSQLColumns>& _rColumns, 51cdf0e10cSrcweir sal_Bool _bCase, 52cdf0e10cSrcweir ::cppu::OWeakObject& _rParent, 53cdf0e10cSrcweir ::osl::Mutex& _rMutex, 54cdf0e10cSrcweir const ::std::vector< ::rtl::OUString> &_rVector, 55cdf0e10cSrcweir sal_Bool _bUseAsIndex 56cdf0e10cSrcweir ) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector,_bUseAsIndex) 57cdf0e10cSrcweir ,m_aColumns(_rColumns) 58cdf0e10cSrcweir { 59cdf0e10cSrcweir } 60cdf0e10cSrcweir 61cdf0e10cSrcweir // ------------------------------------------------------------------------- createWithIntrinsicNames(const::vos::ORef<::connectivity::OSQLColumns> & _rColumns,sal_Bool _bCase,::cppu::OWeakObject & _rParent,::osl::Mutex & _rMutex)62cdf0e10cSrcweir OPrivateColumns* OPrivateColumns::createWithIntrinsicNames( const ::vos::ORef< ::connectivity::OSQLColumns >& _rColumns, 63cdf0e10cSrcweir sal_Bool _bCase, ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex ) 64cdf0e10cSrcweir { 65cdf0e10cSrcweir ::std::vector< ::rtl::OUString > aNames; aNames.reserve( _rColumns->get().size() ); 66cdf0e10cSrcweir 67cdf0e10cSrcweir ::rtl::OUString sColumName; 68cdf0e10cSrcweir for ( ::connectivity::OSQLColumns::Vector::const_iterator column = _rColumns->get().begin(); 69cdf0e10cSrcweir column != _rColumns->get().end(); 70cdf0e10cSrcweir ++column 71cdf0e10cSrcweir ) 72cdf0e10cSrcweir { 73cdf0e10cSrcweir Reference< XPropertySet > xColumn( *column, UNO_QUERY_THROW ); 74cdf0e10cSrcweir xColumn->getPropertyValue( PROPERTY_NAME ) >>= sColumName; 75cdf0e10cSrcweir aNames.push_back( sColumName ); 76cdf0e10cSrcweir } 77cdf0e10cSrcweir return new OPrivateColumns( _rColumns, _bCase, _rParent, _rMutex, aNames, sal_False ); 78cdf0e10cSrcweir } 79cdf0e10cSrcweir 80cdf0e10cSrcweir // ------------------------------------------------------------------------- disposing(void)81cdf0e10cSrcweir void SAL_CALL OPrivateColumns::disposing(void) 82cdf0e10cSrcweir { 83cdf0e10cSrcweir m_aColumns = NULL; 84cdf0e10cSrcweir clear_NoDispose(); 85cdf0e10cSrcweir // we're not owner of the objects we're holding, instead the object we got in our ctor is 86cdf0e10cSrcweir // So we're not allowed to dispose our elements. 87cdf0e10cSrcweir OPrivateColumns_Base::disposing(); 88cdf0e10cSrcweir } 89cdf0e10cSrcweir // ------------------------------------------------------------------------- createObject(const::rtl::OUString & _rName)90cdf0e10cSrcweir connectivity::sdbcx::ObjectType OPrivateColumns::createObject(const ::rtl::OUString& _rName) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir if ( m_aColumns.isValid() ) 93cdf0e10cSrcweir { 94cdf0e10cSrcweir ::connectivity::OSQLColumns::Vector::const_iterator aIter = find(m_aColumns->get().begin(),m_aColumns->get().end(),_rName,isCaseSensitive()); 95cdf0e10cSrcweir if(aIter == m_aColumns->get().end()) 96cdf0e10cSrcweir aIter = findRealName(m_aColumns->get().begin(),m_aColumns->get().end(),_rName,isCaseSensitive()); 97cdf0e10cSrcweir 98cdf0e10cSrcweir if(aIter != m_aColumns->get().end()) 99cdf0e10cSrcweir return connectivity::sdbcx::ObjectType(*aIter,UNO_QUERY); 100cdf0e10cSrcweir 101cdf0e10cSrcweir OSL_ENSURE(0,"Column not found in collection!"); 102cdf0e10cSrcweir } 103cdf0e10cSrcweir return NULL; 104cdf0e10cSrcweir } 105cdf0e10cSrcweir // ------------------------------------------------------------------------- createObject(const::rtl::OUString & _rName)106cdf0e10cSrcweir connectivity::sdbcx::ObjectType OPrivateTables::createObject(const ::rtl::OUString& _rName) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir if ( !m_aTables.empty() ) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir OSQLTables::iterator aIter = m_aTables.find(_rName); 111cdf0e10cSrcweir OSL_ENSURE(aIter != m_aTables.end(),"Table not found!"); 112cdf0e10cSrcweir OSL_ENSURE(aIter->second.is(),"Table is null!"); 113cdf0e10cSrcweir return connectivity::sdbcx::ObjectType(m_aTables.find(_rName)->second,UNO_QUERY); 114cdf0e10cSrcweir } 115cdf0e10cSrcweir return NULL; 116cdf0e10cSrcweir } 117cdf0e10cSrcweir // ----------------------------------------------------------------------------- 118cdf0e10cSrcweir } 119