1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
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"
34 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
35 #include "dbastrings.hrc"
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
,
56 ::cppu::OWeakObject
& _rParent
,
57 ::osl::Mutex
& _rMutex
,
58 const ::std::vector
< ::rtl::OUString
> &_rVector
,
60 ) : sdbcx::OCollection(_rParent
,_bCase
,_rMutex
,_rVector
,_bUseAsIndex
)
61 ,m_aColumns(_rColumns
)
65 // -------------------------------------------------------------------------
66 OPrivateColumns
* OPrivateColumns::createWithIntrinsicNames( const ::vos::ORef
< ::connectivity::OSQLColumns
>& _rColumns
,
67 sal_Bool _bCase
, ::cppu::OWeakObject
& _rParent
, ::osl::Mutex
& _rMutex
)
69 ::std::vector
< ::rtl::OUString
> aNames
; aNames
.reserve( _rColumns
->get().size() );
71 ::rtl::OUString sColumName
;
72 for ( ::connectivity::OSQLColumns::Vector::const_iterator column
= _rColumns
->get().begin();
73 column
!= _rColumns
->get().end();
77 Reference
< XPropertySet
> xColumn( *column
, UNO_QUERY_THROW
);
78 xColumn
->getPropertyValue( PROPERTY_NAME
) >>= sColumName
;
79 aNames
.push_back( sColumName
);
81 return new OPrivateColumns( _rColumns
, _bCase
, _rParent
, _rMutex
, aNames
, sal_False
);
84 // -------------------------------------------------------------------------
85 void SAL_CALL
OPrivateColumns::disposing(void)
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();
93 // -------------------------------------------------------------------------
94 connectivity::sdbcx::ObjectType
OPrivateColumns::createObject(const ::rtl::OUString
& _rName
)
96 if ( m_aColumns
.isValid() )
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());
102 if(aIter
!= m_aColumns
->get().end())
103 return connectivity::sdbcx::ObjectType(*aIter
,UNO_QUERY
);
105 OSL_ENSURE(0,"Column not found in collection!");
109 // -------------------------------------------------------------------------
110 connectivity::sdbcx::ObjectType
OPrivateTables::createObject(const ::rtl::OUString
& _rName
)
112 if ( !m_aTables
.empty() )
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
);
121 // -----------------------------------------------------------------------------