2010-10-12 15:59:03 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-14 17:39:53 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2006-09-17 05:31:33 +00:00
|
|
|
|
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;
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2010-10-15 12:22:54 -05:00
|
|
|
OPrivateColumns::OPrivateColumns(const ::rtl::Reference< ::connectivity::OSQLColumns>& _rColumns,
|
2003-12-16 11:39:23 +00:00
|
|
|
sal_Bool _bCase,
|
|
|
|
::cppu::OWeakObject& _rParent,
|
|
|
|
::osl::Mutex& _rMutex,
|
2013-04-07 12:06:47 +02:00
|
|
|
const ::std::vector< OUString> &_rVector,
|
2003-12-16 11:39:23 +00:00
|
|
|
sal_Bool _bUseAsIndex
|
|
|
|
) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector,_bUseAsIndex)
|
|
|
|
,m_aColumns(_rColumns)
|
|
|
|
{
|
|
|
|
}
|
2006-07-10 14:02:11 +00:00
|
|
|
|
2010-10-15 12:22:54 -05:00
|
|
|
OPrivateColumns* OPrivateColumns::createWithIntrinsicNames( const ::rtl::Reference< ::connectivity::OSQLColumns >& _rColumns,
|
2006-07-10 14:02:11 +00:00
|
|
|
sal_Bool _bCase, ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex )
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
::std::vector< OUString > aNames; aNames.reserve( _rColumns->get().size() );
|
2006-07-10 14:02:11 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
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();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
connectivity::sdbcx::ObjectType OPrivateColumns::createObject(const OUString& _rName)
|
2003-12-16 11:39:23 +00:00
|
|
|
{
|
2010-10-15 12:22:54 -05:00
|
|
|
if ( m_aColumns.is() )
|
2003-12-16 11:39:23 +00:00
|
|
|
{
|
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
|
|
|
|
2011-03-12 12:04:35 +01:00
|
|
|
OSL_FAIL("Column not found in collection!");
|
2003-12-16 11:39:23 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
connectivity::sdbcx::ObjectType OPrivateTables::createObject(const 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!");
|
2011-01-28 09:17:32 +00:00
|
|
|
(void)aIter;
|
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;
|
|
|
|
}
|
|
|
|
}
|
2010-10-12 15:59:03 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|