2003-12-16 11:39:23 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 11:23:57 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2003-12-16 11:39:23 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2003-12-16 11:39:23 +00:00
|
|
|
*
|
2008-04-10 11:23:57 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2003-12-16 11:39:23 +00:00
|
|
|
*
|
2008-04-10 11:23:57 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2003-12-16 11:39:23 +00:00
|
|
|
*
|
2008-04-10 11:23:57 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2003-12-16 11:39:23 +00:00
|
|
|
*
|
2008-04-10 11:23:57 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2003-12-16 11:39:23 +00:00
|
|
|
*
|
2008-04-10 11:23:57 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2003-12-16 11:39:23 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-17 05:31:33 +00:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_dbaccess.hxx"
|
2003-12-16 11:39:23 +00:00
|
|
|
#include "HelperCollections.hxx"
|
|
|
|
|
2006-07-10 14:02:11 +00:00
|
|
|
#include "dbastrings.hrc"
|
|
|
|
|
2003-12-16 11:39:23 +00:00
|
|
|
namespace dbaccess
|
|
|
|
{
|
|
|
|
using namespace dbtools;
|
|
|
|
using namespace comphelper;
|
|
|
|
using namespace connectivity;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::sdb;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::script;
|
|
|
|
using namespace ::cppu;
|
|
|
|
using namespace ::osl;
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
OPrivateColumns::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
|
|
|
|
) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector,_bUseAsIndex)
|
|
|
|
,m_aColumns(_rColumns)
|
|
|
|
{
|
|
|
|
}
|
2006-07-10 14:02:11 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
OPrivateColumns* OPrivateColumns::createWithIntrinsicNames( const ::vos::ORef< ::connectivity::OSQLColumns >& _rColumns,
|
|
|
|
sal_Bool _bCase, ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex )
|
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
::std::vector< ::rtl::OUString > aNames; aNames.reserve( _rColumns->get().size() );
|
2006-07-10 14:02:11 +00:00
|
|
|
|
|
|
|
::rtl::OUString sColumName;
|
2008-12-30 13:32:01 +00:00
|
|
|
for ( ::connectivity::OSQLColumns::Vector::const_iterator column = _rColumns->get().begin();
|
|
|
|
column != _rColumns->get().end();
|
2006-07-10 14:02:11 +00:00
|
|
|
++column
|
|
|
|
)
|
|
|
|
{
|
|
|
|
Reference< XPropertySet > xColumn( *column, UNO_QUERY_THROW );
|
|
|
|
xColumn->getPropertyValue( PROPERTY_NAME ) >>= sColumName;
|
|
|
|
aNames.push_back( sColumName );
|
|
|
|
}
|
|
|
|
return new OPrivateColumns( _rColumns, _bCase, _rParent, _rMutex, aNames, sal_False );
|
|
|
|
}
|
|
|
|
|
2003-12-16 11:39:23 +00:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OPrivateColumns::disposing(void)
|
|
|
|
{
|
|
|
|
m_aColumns = NULL;
|
|
|
|
clear_NoDispose();
|
|
|
|
// we're not owner of the objects we're holding, instead the object we got in our ctor is
|
|
|
|
// So we're not allowed to dispose our elements.
|
|
|
|
OPrivateColumns_Base::disposing();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2005-03-10 15:30:24 +00:00
|
|
|
connectivity::sdbcx::ObjectType OPrivateColumns::createObject(const ::rtl::OUString& _rName)
|
2003-12-16 11:39:23 +00:00
|
|
|
{
|
|
|
|
if ( m_aColumns.isValid() )
|
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
::connectivity::OSQLColumns::Vector::const_iterator aIter = find(m_aColumns->get().begin(),m_aColumns->get().end(),_rName,isCaseSensitive());
|
|
|
|
if(aIter == m_aColumns->get().end())
|
|
|
|
aIter = findRealName(m_aColumns->get().begin(),m_aColumns->get().end(),_rName,isCaseSensitive());
|
2003-12-16 11:39:23 +00:00
|
|
|
|
2008-12-30 13:32:01 +00:00
|
|
|
if(aIter != m_aColumns->get().end())
|
2005-03-10 15:30:24 +00:00
|
|
|
return connectivity::sdbcx::ObjectType(*aIter,UNO_QUERY);
|
2003-12-16 11:39:23 +00:00
|
|
|
|
|
|
|
OSL_ENSURE(0,"Column not found in collection!");
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2005-03-10 15:30:24 +00:00
|
|
|
connectivity::sdbcx::ObjectType OPrivateTables::createObject(const ::rtl::OUString& _rName)
|
2003-12-16 11:39:23 +00:00
|
|
|
{
|
|
|
|
if ( !m_aTables.empty() )
|
|
|
|
{
|
|
|
|
OSQLTables::iterator aIter = m_aTables.find(_rName);
|
|
|
|
OSL_ENSURE(aIter != m_aTables.end(),"Table not found!");
|
|
|
|
OSL_ENSURE(aIter->second.is(),"Table is null!");
|
2005-03-10 15:30:24 +00:00
|
|
|
return connectivity::sdbcx::ObjectType(m_aTables.find(_rName)->second,UNO_QUERY);
|
2003-12-16 11:39:23 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
}
|