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_dbaccess.hxx" 30 #ifndef DBA_HELPERCOLLECTIONS_HXX 31 #include "HelperCollections.hxx" 32 #endif 33 34 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC 35 #include "dbastrings.hrc" 36 #endif 37 38 namespace dbaccess 39 { 40 using namespace dbtools; 41 using namespace comphelper; 42 using namespace connectivity; 43 using namespace ::com::sun::star::uno; 44 using namespace ::com::sun::star::beans; 45 using namespace ::com::sun::star::sdbc; 46 using namespace ::com::sun::star::sdb; 47 using namespace ::com::sun::star::sdbcx; 48 using namespace ::com::sun::star::container; 49 using namespace ::com::sun::star::lang; 50 using namespace ::com::sun::star::script; 51 using namespace ::cppu; 52 using namespace ::osl; 53 // ----------------------------------------------------------------------------- 54 OPrivateColumns::OPrivateColumns(const ::vos::ORef< ::connectivity::OSQLColumns>& _rColumns, 55 sal_Bool _bCase, 56 ::cppu::OWeakObject& _rParent, 57 ::osl::Mutex& _rMutex, 58 const ::std::vector< ::rtl::OUString> &_rVector, 59 sal_Bool _bUseAsIndex 60 ) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector,_bUseAsIndex) 61 ,m_aColumns(_rColumns) 62 { 63 } 64 65 // ------------------------------------------------------------------------- 66 OPrivateColumns* OPrivateColumns::createWithIntrinsicNames( const ::vos::ORef< ::connectivity::OSQLColumns >& _rColumns, 67 sal_Bool _bCase, ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex ) 68 { 69 ::std::vector< ::rtl::OUString > aNames; aNames.reserve( _rColumns->get().size() ); 70 71 ::rtl::OUString sColumName; 72 for ( ::connectivity::OSQLColumns::Vector::const_iterator column = _rColumns->get().begin(); 73 column != _rColumns->get().end(); 74 ++column 75 ) 76 { 77 Reference< XPropertySet > xColumn( *column, UNO_QUERY_THROW ); 78 xColumn->getPropertyValue( PROPERTY_NAME ) >>= sColumName; 79 aNames.push_back( sColumName ); 80 } 81 return new OPrivateColumns( _rColumns, _bCase, _rParent, _rMutex, aNames, sal_False ); 82 } 83 84 // ------------------------------------------------------------------------- 85 void SAL_CALL OPrivateColumns::disposing(void) 86 { 87 m_aColumns = NULL; 88 clear_NoDispose(); 89 // we're not owner of the objects we're holding, instead the object we got in our ctor is 90 // So we're not allowed to dispose our elements. 91 OPrivateColumns_Base::disposing(); 92 } 93 // ------------------------------------------------------------------------- 94 connectivity::sdbcx::ObjectType OPrivateColumns::createObject(const ::rtl::OUString& _rName) 95 { 96 if ( m_aColumns.isValid() ) 97 { 98 ::connectivity::OSQLColumns::Vector::const_iterator aIter = find(m_aColumns->get().begin(),m_aColumns->get().end(),_rName,isCaseSensitive()); 99 if(aIter == m_aColumns->get().end()) 100 aIter = findRealName(m_aColumns->get().begin(),m_aColumns->get().end(),_rName,isCaseSensitive()); 101 102 if(aIter != m_aColumns->get().end()) 103 return connectivity::sdbcx::ObjectType(*aIter,UNO_QUERY); 104 105 OSL_ENSURE(0,"Column not found in collection!"); 106 } 107 return NULL; 108 } 109 // ------------------------------------------------------------------------- 110 connectivity::sdbcx::ObjectType OPrivateTables::createObject(const ::rtl::OUString& _rName) 111 { 112 if ( !m_aTables.empty() ) 113 { 114 OSQLTables::iterator aIter = m_aTables.find(_rName); 115 OSL_ENSURE(aIter != m_aTables.end(),"Table not found!"); 116 OSL_ENSURE(aIter->second.is(),"Table is null!"); 117 return connectivity::sdbcx::ObjectType(m_aTables.find(_rName)->second,UNO_QUERY); 118 } 119 return NULL; 120 } 121 // ----------------------------------------------------------------------------- 122 } 123