merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / core / api / HelperCollections.cxx
blobafa77cececdf5488dc9a2bd82de336c940c6c629
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: HelperCollections.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef DBA_HELPERCOLLECTIONS_HXX
34 #include "HelperCollections.hxx"
35 #endif
37 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
38 #include "dbastrings.hrc"
39 #endif
41 namespace dbaccess
43 using namespace dbtools;
44 using namespace comphelper;
45 using namespace connectivity;
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::beans;
48 using namespace ::com::sun::star::sdbc;
49 using namespace ::com::sun::star::sdb;
50 using namespace ::com::sun::star::sdbcx;
51 using namespace ::com::sun::star::container;
52 using namespace ::com::sun::star::lang;
53 using namespace ::com::sun::star::script;
54 using namespace ::cppu;
55 using namespace ::osl;
56 // -----------------------------------------------------------------------------
57 OPrivateColumns::OPrivateColumns(const ::vos::ORef< ::connectivity::OSQLColumns>& _rColumns,
58 sal_Bool _bCase,
59 ::cppu::OWeakObject& _rParent,
60 ::osl::Mutex& _rMutex,
61 const ::std::vector< ::rtl::OUString> &_rVector,
62 sal_Bool _bUseAsIndex
63 ) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector,_bUseAsIndex)
64 ,m_aColumns(_rColumns)
68 // -------------------------------------------------------------------------
69 OPrivateColumns* OPrivateColumns::createWithIntrinsicNames( const ::vos::ORef< ::connectivity::OSQLColumns >& _rColumns,
70 sal_Bool _bCase, ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex )
72 ::std::vector< ::rtl::OUString > aNames; aNames.reserve( _rColumns->get().size() );
74 ::rtl::OUString sColumName;
75 for ( ::connectivity::OSQLColumns::Vector::const_iterator column = _rColumns->get().begin();
76 column != _rColumns->get().end();
77 ++column
80 Reference< XPropertySet > xColumn( *column, UNO_QUERY_THROW );
81 xColumn->getPropertyValue( PROPERTY_NAME ) >>= sColumName;
82 aNames.push_back( sColumName );
84 return new OPrivateColumns( _rColumns, _bCase, _rParent, _rMutex, aNames, sal_False );
87 // -------------------------------------------------------------------------
88 void SAL_CALL OPrivateColumns::disposing(void)
90 m_aColumns = NULL;
91 clear_NoDispose();
92 // we're not owner of the objects we're holding, instead the object we got in our ctor is
93 // So we're not allowed to dispose our elements.
94 OPrivateColumns_Base::disposing();
96 // -------------------------------------------------------------------------
97 connectivity::sdbcx::ObjectType OPrivateColumns::createObject(const ::rtl::OUString& _rName)
99 if ( m_aColumns.isValid() )
101 ::connectivity::OSQLColumns::Vector::const_iterator aIter = find(m_aColumns->get().begin(),m_aColumns->get().end(),_rName,isCaseSensitive());
102 if(aIter == m_aColumns->get().end())
103 aIter = findRealName(m_aColumns->get().begin(),m_aColumns->get().end(),_rName,isCaseSensitive());
105 if(aIter != m_aColumns->get().end())
106 return connectivity::sdbcx::ObjectType(*aIter,UNO_QUERY);
108 OSL_ENSURE(0,"Column not found in collection!");
110 return NULL;
112 // -------------------------------------------------------------------------
113 connectivity::sdbcx::ObjectType OPrivateTables::createObject(const ::rtl::OUString& _rName)
115 if ( !m_aTables.empty() )
117 OSQLTables::iterator aIter = m_aTables.find(_rName);
118 OSL_ENSURE(aIter != m_aTables.end(),"Table not found!");
119 OSL_ENSURE(aIter->second.is(),"Table is null!");
120 return connectivity::sdbcx::ObjectType(m_aTables.find(_rName)->second,UNO_QUERY);
122 return NULL;
124 // -----------------------------------------------------------------------------