LCOV - code coverage report
Current view: top level - libreoffice/connectivity/source/sdbcx - VCatalog.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 14 94 14.9 %
Date: 2012-12-27 Functions: 4 18 22.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include "connectivity/sdbcx/VCatalog.hxx"
      21             : #include "connectivity/sdbcx/VCollection.hxx"
      22             : #include <com/sun/star/lang/DisposedException.hpp>
      23             : #include "connectivity/sdbcx/VDescriptor.hxx"
      24             : #include "TConnection.hxx"
      25             : #include <comphelper/uno3.hxx>
      26             : #include "connectivity/dbtools.hxx"
      27             : 
      28             : using namespace connectivity;
      29             : using namespace connectivity::sdbcx;
      30             : using namespace ::com::sun::star::beans;
      31             : using namespace ::com::sun::star::uno;
      32             : using namespace ::com::sun::star::sdbc;
      33             : using namespace ::com::sun::star::sdbcx;
      34             : using namespace ::com::sun::star::container;
      35             : using namespace ::com::sun::star::lang;
      36             : //------------------------------------------------------------------------------
      37           0 : IMPLEMENT_SERVICE_INFO(OCatalog,"com.sun.star.comp.connectivity.OCatalog","com.sun.star.sdbcx.DatabaseDefinition")
      38             : //------------------------------------------------------------------------------
      39           2 : OCatalog::OCatalog(const Reference< XConnection> &_xConnection) : OCatalog_BASE(m_aMutex)
      40             :             ,connectivity::OSubComponent<OCatalog, OCatalog_BASE>(_xConnection, this)
      41             :             ,m_pTables(NULL)
      42             :             ,m_pViews(NULL)
      43             :             ,m_pGroups(NULL)
      44           2 :             ,m_pUsers(NULL)
      45             : {
      46             :     try
      47             :     {
      48           2 :         m_xMetaData = _xConnection->getMetaData();
      49             :     }
      50           0 :     catch(const Exception&)
      51             :     {
      52             :         OSL_FAIL("No Metadata available!");
      53             :     }
      54           2 : }
      55             : //-----------------------------------------------------------------------------
      56           0 : OCatalog::~OCatalog()
      57             : {
      58           0 :     delete m_pTables;
      59           0 :     delete m_pViews;
      60           0 :     delete m_pGroups;
      61           0 :     delete m_pUsers;
      62           0 : }
      63             : //-----------------------------------------------------------------------------
      64           8 : void SAL_CALL OCatalog::acquire() throw()
      65             : {
      66           8 :     OCatalog_BASE::acquire();
      67           8 : }
      68             : //------------------------------------------------------------------------------
      69           4 : void SAL_CALL OCatalog::release() throw()
      70             : {
      71           4 :     relase_ChildImpl();
      72           4 : }
      73             : 
      74             : //------------------------------------------------------------------------------
      75           0 : void SAL_CALL OCatalog::disposing()
      76             : {
      77           0 :     ::osl::MutexGuard aGuard(m_aMutex);
      78             : 
      79           0 :     if(m_pTables)
      80           0 :         m_pTables->disposing();
      81           0 :     if(m_pViews)
      82           0 :         m_pViews->disposing();
      83           0 :     if(m_pGroups)
      84           0 :         m_pGroups->disposing();
      85           0 :     if(m_pUsers)
      86           0 :         m_pUsers->disposing();
      87             : 
      88           0 :     dispose_ChildImpl();
      89           0 :     OCatalog_BASE::disposing();
      90           0 : }
      91             : //------------------------------------------------------------------------------
      92             : // XTablesSupplier
      93           0 : Reference< XNameAccess > SAL_CALL OCatalog::getTables(  ) throw(RuntimeException)
      94             : {
      95           0 :     ::osl::MutexGuard aGuard(m_aMutex);
      96           0 :     checkDisposed(OCatalog_BASE::rBHelper.bDisposed);
      97             : 
      98             :     try
      99             :     {
     100           0 :         if(!m_pTables)
     101           0 :             refreshTables();
     102             :     }
     103           0 :     catch( const RuntimeException& )
     104             :     {
     105             :         // allowed to leave this method
     106           0 :         throw;
     107             :     }
     108           0 :     catch( const Exception& )
     109             :     {
     110             :         // allowed
     111             :     }
     112             : 
     113           0 :     return const_cast<OCatalog*>(this)->m_pTables;
     114             : }
     115             : // -------------------------------------------------------------------------
     116             : // XViewsSupplier
     117           0 : Reference< XNameAccess > SAL_CALL OCatalog::getViews(  ) throw(RuntimeException)
     118             : {
     119           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     120           0 :     checkDisposed(OCatalog_BASE::rBHelper.bDisposed);
     121             : 
     122             :     try
     123             :     {
     124           0 :         if(!m_pViews)
     125           0 :             refreshViews();
     126             :     }
     127           0 :     catch( const RuntimeException& )
     128             :     {
     129             :         // allowed to leave this method
     130           0 :         throw;
     131             :     }
     132           0 :     catch( const Exception& )
     133             :     {
     134             :         // allowed
     135             :     }
     136             : 
     137           0 :     return const_cast<OCatalog*>(this)->m_pViews;
     138             : }
     139             : // -------------------------------------------------------------------------
     140             : // XUsersSupplier
     141           0 : Reference< XNameAccess > SAL_CALL OCatalog::getUsers(  ) throw(RuntimeException)
     142             : {
     143           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     144           0 :     checkDisposed(OCatalog_BASE::rBHelper.bDisposed);
     145             : 
     146             :     try
     147             :     {
     148           0 :         if(!m_pUsers)
     149           0 :             refreshUsers();
     150             :     }
     151           0 :     catch( const RuntimeException& )
     152             :     {
     153             :         // allowed to leave this method
     154           0 :         throw;
     155             :     }
     156           0 :     catch( const Exception& )
     157             :     {
     158             :         // allowed
     159             :     }
     160             : 
     161           0 :     return const_cast<OCatalog*>(this)->m_pUsers;
     162             : }
     163             : // -------------------------------------------------------------------------
     164             : // XGroupsSupplier
     165           0 : Reference< XNameAccess > SAL_CALL OCatalog::getGroups(  ) throw(RuntimeException)
     166             : {
     167           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     168           0 :     checkDisposed(OCatalog_BASE::rBHelper.bDisposed);
     169             : 
     170             :     try
     171             :     {
     172           0 :         if(!m_pGroups)
     173           0 :             refreshGroups();
     174             :     }
     175           0 :     catch( const RuntimeException& )
     176             :     {
     177             :         // allowed to leave this method
     178           0 :         throw;
     179             :     }
     180           0 :     catch( const Exception& )
     181             :     {
     182             :         // allowed
     183             :     }
     184             : 
     185           0 :     return const_cast<OCatalog*>(this)->m_pGroups;
     186             : }
     187             : // -----------------------------------------------------------------------------
     188           0 : ::rtl::OUString OCatalog::buildName(const Reference< XRow >& _xRow)
     189             : {
     190           0 :     ::rtl::OUString sCatalog = _xRow->getString(1);
     191           0 :     if ( _xRow->wasNull() )
     192           0 :         sCatalog = ::rtl::OUString();
     193           0 :     ::rtl::OUString sSchema  = _xRow->getString(2);
     194           0 :     if ( _xRow->wasNull() )
     195           0 :         sSchema = ::rtl::OUString();
     196           0 :     ::rtl::OUString sTable   = _xRow->getString(3);
     197           0 :     if ( _xRow->wasNull() )
     198           0 :         sTable = ::rtl::OUString();
     199             : 
     200             :     ::rtl::OUString sComposedName(
     201           0 :         ::dbtools::composeTableName( m_xMetaData, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation ) );
     202           0 :     return sComposedName;
     203             : }
     204             : // -----------------------------------------------------------------------------
     205           0 : void OCatalog::fillNames(Reference< XResultSet >& _xResult,TStringVector& _rNames)
     206             : {
     207           0 :     if ( _xResult.is() )
     208             :     {
     209           0 :         _rNames.reserve(20);
     210           0 :         Reference< XRow > xRow(_xResult,UNO_QUERY);
     211           0 :         while ( _xResult->next() )
     212             :         {
     213           0 :             _rNames.push_back( buildName(xRow) );
     214             :         }
     215           0 :         xRow.clear();
     216           0 :         ::comphelper::disposeComponent(_xResult);
     217             :     }
     218           0 : }
     219             : // -------------------------------------------------------------------------
     220          79 : void ODescriptor::construct()
     221             : {
     222          79 :     sal_Int32 nAttrib = isNew() ? 0 : ::com::sun::star::beans::PropertyAttribute::READONLY;
     223          79 :     registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME), PROPERTY_ID_NAME ,nAttrib,&m_Name,::getCppuType(static_cast< ::rtl::OUString*>(0)));
     224          79 : }
     225             : // -------------------------------------------------------------------------
     226           0 : ODescriptor::~ODescriptor()
     227             : {
     228           0 : }
     229             : // -----------------------------------------------------------------------------
     230             : 
     231             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10