nss: upgrade to release 3.73
[LibreOffice.git] / connectivity / source / sdbcx / VCatalog.cxx
blobb30519fcaab1c329acd5b65606200382c145240d
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 <comphelper/types.hxx>
21 #include <sdbcx/VCatalog.hxx>
22 #include <connectivity/sdbcx/VCollection.hxx>
23 #include <com/sun/star/sdbc/XRow.hpp>
24 #include <connectivity/sdbcx/VDescriptor.hxx>
25 #include <com/sun/star/beans/PropertyAttribute.hpp>
26 #include <TConnection.hxx>
27 #include <connectivity/dbtools.hxx>
29 using namespace connectivity;
30 using namespace connectivity::sdbcx;
31 using namespace ::com::sun::star::beans;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::sdbc;
34 using namespace ::com::sun::star::sdbcx;
35 using namespace ::com::sun::star::container;
36 using namespace ::com::sun::star::lang;
38 IMPLEMENT_SERVICE_INFO(OCatalog,"com.sun.star.comp.connectivity.OCatalog","com.sun.star.sdbcx.DatabaseDefinition")
40 OCatalog::OCatalog(const Reference< XConnection> &_xConnection) : OCatalog_BASE(m_aMutex)
42 try
44 m_xMetaData = _xConnection->getMetaData();
46 catch(const Exception&)
48 OSL_FAIL("No Metadata available!");
52 OCatalog::~OCatalog()
56 void SAL_CALL OCatalog::disposing()
58 ::osl::MutexGuard aGuard(m_aMutex);
60 if(m_pTables)
61 m_pTables->disposing();
62 if(m_pViews)
63 m_pViews->disposing();
64 if(m_pGroups)
65 m_pGroups->disposing();
66 if(m_pUsers)
67 m_pUsers->disposing();
69 OCatalog_BASE::disposing();
72 // XTablesSupplier
73 Reference< XNameAccess > SAL_CALL OCatalog::getTables( )
75 ::osl::MutexGuard aGuard(m_aMutex);
76 checkDisposed(OCatalog_BASE::rBHelper.bDisposed);
78 try
80 if(!m_pTables)
81 refreshTables();
83 catch( const RuntimeException& )
85 // allowed to leave this method
86 throw;
88 catch( const Exception& )
90 // allowed
93 return m_pTables.get();
96 // XViewsSupplier
97 Reference< XNameAccess > SAL_CALL OCatalog::getViews( )
99 ::osl::MutexGuard aGuard(m_aMutex);
100 checkDisposed(OCatalog_BASE::rBHelper.bDisposed);
104 if(!m_pViews)
105 refreshViews();
107 catch( const RuntimeException& )
109 // allowed to leave this method
110 throw;
112 catch( const Exception& )
114 // allowed
117 return m_pViews.get();
120 // XUsersSupplier
121 Reference< XNameAccess > SAL_CALL OCatalog::getUsers( )
123 ::osl::MutexGuard aGuard(m_aMutex);
124 checkDisposed(OCatalog_BASE::rBHelper.bDisposed);
128 if(!m_pUsers)
129 refreshUsers();
131 catch( const RuntimeException& )
133 // allowed to leave this method
134 throw;
136 catch( const Exception& )
138 // allowed
141 return m_pUsers.get();
144 // XGroupsSupplier
145 Reference< XNameAccess > SAL_CALL OCatalog::getGroups( )
147 ::osl::MutexGuard aGuard(m_aMutex);
148 checkDisposed(OCatalog_BASE::rBHelper.bDisposed);
152 if(!m_pGroups)
153 refreshGroups();
155 catch( const RuntimeException& )
157 // allowed to leave this method
158 throw;
160 catch( const Exception& )
162 // allowed
165 return m_pGroups.get();
168 OUString OCatalog::buildName(const Reference< XRow >& _xRow)
170 OUString sCatalog = _xRow->getString(1);
171 if ( _xRow->wasNull() )
172 sCatalog.clear();
173 OUString sSchema = _xRow->getString(2);
174 if ( _xRow->wasNull() )
175 sSchema.clear();
176 OUString sTable = _xRow->getString(3);
177 if ( _xRow->wasNull() )
178 sTable.clear();
180 OUString sComposedName(
181 ::dbtools::composeTableName( m_xMetaData, sCatalog, sSchema, sTable, false, ::dbtools::EComposeRule::InDataManipulation ) );
182 return sComposedName;
185 void OCatalog::fillNames(Reference< XResultSet >& _xResult,::std::vector< OUString>& _rNames)
187 if ( _xResult.is() )
189 _rNames.reserve(20);
190 Reference< XRow > xRow(_xResult,UNO_QUERY);
191 while ( _xResult->next() )
193 _rNames.push_back( buildName(xRow) );
195 xRow.clear();
196 ::comphelper::disposeComponent(_xResult);
200 void ODescriptor::construct()
202 sal_Int32 nAttrib = isNew() ? 0 : css::beans::PropertyAttribute::READONLY;
203 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME), PROPERTY_ID_NAME ,nAttrib,&m_Name,::cppu::UnoType<OUString>::get());
206 ODescriptor::~ODescriptor()
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */