nss: upgrade to release 3.73
[LibreOffice.git] / dbaccess / source / core / api / HelperCollections.cxx
blobdfc18badc6881cf646c209b637eae093d54d14e8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "HelperCollections.hxx"
22 #include <strings.hxx>
24 #include <osl/diagnose.h>
26 namespace dbaccess
28 using namespace dbtools;
29 using namespace comphelper;
30 using namespace connectivity;
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::beans;
33 using namespace ::com::sun::star::sdbc;
34 using namespace ::com::sun::star::sdb;
35 using namespace ::com::sun::star::sdbcx;
36 using namespace ::com::sun::star::container;
37 using namespace ::com::sun::star::lang;
38 using namespace ::com::sun::star::script;
39 using namespace ::cppu;
40 using namespace ::osl;
42 OPrivateColumns::OPrivateColumns(const ::rtl::Reference< ::connectivity::OSQLColumns>& _rColumns,
43 bool _bCase,
44 ::cppu::OWeakObject& _rParent,
45 ::osl::Mutex& _rMutex,
46 const std::vector< OUString> &_rVector,
47 bool _bUseAsIndex
48 ) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector,_bUseAsIndex)
49 ,m_aColumns(_rColumns)
53 std::unique_ptr<OPrivateColumns> OPrivateColumns::createWithIntrinsicNames( const ::rtl::Reference< ::connectivity::OSQLColumns >& _rColumns,
54 bool _bCase, ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex )
56 std::vector< OUString > aNames; aNames.reserve( _rColumns->size() );
58 OUString sColumName;
59 for (auto const& column : *_rColumns)
61 Reference< XPropertySet > xColumn(column, UNO_SET_THROW);
62 xColumn->getPropertyValue( PROPERTY_NAME ) >>= sColumName;
63 aNames.push_back( sColumName );
65 return std::unique_ptr<OPrivateColumns>(new OPrivateColumns( _rColumns, _bCase, _rParent, _rMutex, aNames, false ));
68 void OPrivateColumns::disposing()
70 m_aColumns = nullptr;
71 clear_NoDispose();
72 // we're not owner of the objects we're holding, instead the object we got in our ctor is
73 // So we're not allowed to dispose our elements.
74 OPrivateColumns_Base::disposing();
77 connectivity::sdbcx::ObjectType OPrivateColumns::createObject(const OUString& _rName)
79 if ( m_aColumns.is() )
81 ::connectivity::OSQLColumns::Vector::const_iterator aIter = find(m_aColumns->begin(),m_aColumns->end(),_rName,isCaseSensitive());
82 if(aIter == m_aColumns->end())
83 aIter = findRealName(m_aColumns->begin(),m_aColumns->end(),_rName,isCaseSensitive());
85 if(aIter != m_aColumns->end())
86 return connectivity::sdbcx::ObjectType(*aIter,UNO_QUERY);
88 OSL_FAIL("Column not found in collection!");
90 return nullptr;
93 connectivity::sdbcx::ObjectType OPrivateTables::createObject(const OUString& _rName)
95 if ( !m_aTables.empty() )
97 OSQLTables::iterator aIter = m_aTables.find(_rName);
98 OSL_ENSURE(aIter != m_aTables.end(),"Table not found!");
99 OSL_ENSURE(aIter->second.is(),"Table is null!");
100 return connectivity::sdbcx::ObjectType(m_aTables.find(_rName)->second,UNO_QUERY);
102 return nullptr;
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */