LCOV - code coverage report
Current view: top level - connectivity/source/sdbcx - VTable.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 132 0.0 %
Date: 2014-04-14 Functions: 0 29 0.0 %
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/VTable.hxx"
      21             : #include <com/sun/star/lang/DisposedException.hpp>
      22             : #include "connectivity/sdbcx/VIndex.hxx"
      23             : #include <comphelper/sequence.hxx>
      24             : #include "connectivity/sdbcx/VCollection.hxx"
      25             : #include "TConnection.hxx"
      26             : #include "connectivity/sdbcx/VColumn.hxx"
      27             : #include "connectivity/sdbcx/VKey.hxx"
      28             : #include "connectivity/dbtools.hxx"
      29             : #include <connectivity/dbexception.hxx>
      30             : #include <cppuhelper/supportsservice.hxx>
      31             : 
      32             : using namespace ::connectivity;
      33             : using namespace ::connectivity::sdbcx;
      34             : using namespace ::dbtools;
      35             : using namespace ::com::sun::star::beans;
      36             : using namespace ::com::sun::star::uno;
      37             : using namespace ::com::sun::star::sdbc;
      38             : using namespace ::com::sun::star::sdbcx;
      39             : using namespace ::com::sun::star::container;
      40             : using namespace ::com::sun::star::lang;
      41             : 
      42             : 
      43           0 : OUString SAL_CALL OTable::getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
      44             : {
      45           0 :     if(isNew())
      46           0 :         return OUString("com.sun.star.sdbcx.VTableDescriptor");
      47           0 :     return OUString("com.sun.star.sdbcx.Table");
      48             : }
      49             : 
      50             : 
      51           0 : ::com::sun::star::uno::Sequence< OUString > SAL_CALL OTable::getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException, std::exception)
      52             : {
      53           0 :     ::com::sun::star::uno::Sequence< OUString > aSupported(1);
      54           0 :     if(isNew())
      55           0 :         aSupported[0] = "com.sun.star.sdbcx.TableDescriptor";
      56             :     else
      57           0 :         aSupported[0] = "com.sun.star.sdbcx.Table";
      58             : 
      59           0 :     return aSupported;
      60             : }
      61             : 
      62           0 : sal_Bool SAL_CALL OTable::supportsService( const OUString& _rServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
      63             : {
      64           0 :     return cppu::supportsService(this, _rServiceName);
      65             : }
      66             : 
      67           0 : OTable::OTable(OCollection* _pTables,
      68             :                bool _bCase)
      69             :                : OTableDescriptor_BASE(m_aMutex)
      70             :                 ,ODescriptor(OTableDescriptor_BASE::rBHelper,_bCase,true)
      71             :                 ,m_pKeys(NULL)
      72             :                 ,m_pColumns(NULL)
      73             :                 ,m_pIndexes(NULL)
      74           0 :                 ,m_pTables(_pTables)
      75             : {
      76           0 : }
      77             : 
      78           0 : OTable::OTable( OCollection*    _pTables,
      79             :                 bool            _bCase,
      80             :                 const OUString& _Name,       const OUString& _Type,
      81             :                 const OUString& _Description,const OUString& _SchemaName,
      82             :                 const OUString& _CatalogName) :  OTableDescriptor_BASE(m_aMutex)
      83             :                 ,ODescriptor(OTableDescriptor_BASE::rBHelper,_bCase)
      84             :                 ,m_CatalogName(_CatalogName)
      85             :                 ,m_SchemaName(_SchemaName)
      86             :                 ,m_Description(_Description)
      87             :                 ,m_Type(_Type)
      88             :                 ,m_pKeys(NULL)
      89             :                 ,m_pColumns(NULL)
      90             :                 ,m_pIndexes(NULL)
      91           0 :                 ,m_pTables(_pTables)
      92             : {
      93           0 :     m_Name = _Name;
      94           0 : }
      95             : 
      96           0 : OTable::~OTable()
      97             : {
      98           0 :     delete m_pKeys;
      99           0 :     delete m_pColumns;
     100           0 :     delete m_pIndexes;
     101           0 : }
     102             : 
     103           0 : void OTable::construct()
     104             : {
     105           0 :     ODescriptor::construct();
     106             : 
     107           0 :     sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
     108             : 
     109           0 :     registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME),     PROPERTY_ID_CATALOGNAME,nAttrib,&m_CatalogName, ::getCppuType(static_cast< OUString*>(0)));
     110           0 :     registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME),      PROPERTY_ID_SCHEMANAME, nAttrib,&m_SchemaName,  ::getCppuType(static_cast< OUString*>(0)));
     111           0 :     registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION),     PROPERTY_ID_DESCRIPTION,nAttrib,&m_Description, ::getCppuType(static_cast< OUString*>(0)));
     112           0 :     registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE),            PROPERTY_ID_TYPE,       nAttrib,&m_Type,        ::getCppuType(static_cast< OUString*>(0)));
     113           0 : }
     114             : 
     115           0 : void SAL_CALL OTable::acquire() throw()
     116             : {
     117           0 :     OTableDescriptor_BASE::acquire();
     118           0 : }
     119             : 
     120           0 : void SAL_CALL OTable::release() throw()
     121             : {
     122           0 :     OTableDescriptor_BASE::release();
     123           0 : }
     124             : 
     125             : 
     126           0 : Any SAL_CALL OTable::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
     127             : {
     128           0 :     Any aRet = ODescriptor::queryInterface( rType);
     129           0 :     if(!aRet.hasValue())
     130             :     {
     131           0 :         if(!isNew())
     132           0 :             aRet = OTable_BASE::queryInterface( rType);
     133           0 :         if(isNew() && (rType == getCppuType( (Reference<XIndexesSupplier>*)0)))
     134           0 :             return Any();
     135           0 :         if(!aRet.hasValue())
     136           0 :             aRet = OTableDescriptor_BASE::queryInterface( rType);
     137             :     }
     138           0 :     return aRet;
     139             : }
     140             : 
     141           0 : Sequence< Type > SAL_CALL OTable::getTypes(  ) throw(RuntimeException, std::exception)
     142             : {
     143           0 :     if(isNew())
     144           0 :         return ::comphelper::concatSequences(ODescriptor::getTypes(),OTableDescriptor_BASE::getTypes());
     145           0 :     return ::comphelper::concatSequences(ODescriptor::getTypes(),OTableDescriptor_BASE::getTypes(),OTable_BASE::getTypes());
     146             : }
     147             : 
     148           0 : void SAL_CALL OTable::disposing(void)
     149             : {
     150           0 :     ODescriptor::disposing();
     151             : 
     152           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     153             : 
     154           0 :     if(m_pKeys)
     155           0 :         m_pKeys->disposing();
     156           0 :     if(m_pColumns)
     157           0 :         m_pColumns->disposing();
     158           0 :     if(m_pIndexes)
     159           0 :         m_pIndexes->disposing();
     160             : 
     161           0 :     m_pTables = NULL;
     162           0 : }
     163             : 
     164             : // XColumnsSupplier
     165           0 : Reference< XNameAccess > SAL_CALL OTable::getColumns(  ) throw(RuntimeException, std::exception)
     166             : {
     167           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     168           0 :     checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
     169             : 
     170             :     try
     171             :     {
     172           0 :         if ( !m_pColumns )
     173           0 :             refreshColumns();
     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 m_pColumns;
     186             : }
     187             : 
     188             : 
     189             : // XKeysSupplier
     190           0 : Reference< XIndexAccess > SAL_CALL OTable::getKeys(  ) throw(RuntimeException, std::exception)
     191             : {
     192           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     193           0 :     checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
     194             : 
     195           0 :     Reference< XIndexAccess > xKeys;
     196             : 
     197             :     try
     198             :     {
     199           0 :         if ( !m_pKeys )
     200           0 :             refreshKeys();
     201           0 :         xKeys = m_pKeys;
     202             :     }
     203           0 :     catch( const RuntimeException& )
     204             :     {
     205             :         // allowed to leave this method
     206           0 :         throw;
     207             :     }
     208           0 :     catch( const Exception& )
     209             :     {
     210             :         // allowed
     211             :     }
     212             : 
     213           0 :     return xKeys;
     214             : }
     215             : 
     216           0 : cppu::IPropertyArrayHelper* OTable::createArrayHelper( sal_Int32 /*_nId*/ ) const
     217             : {
     218           0 :     return doCreateArrayHelper();
     219             : }
     220             : 
     221           0 : cppu::IPropertyArrayHelper & OTable::getInfoHelper()
     222             : {
     223           0 :     return *const_cast<OTable*>(this)->getArrayHelper(isNew() ? 1 : 0);
     224             : }
     225             : 
     226           0 : Reference< XPropertySet > SAL_CALL OTable::createDataDescriptor(  ) throw(RuntimeException, std::exception)
     227             : {
     228           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     229           0 :     checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
     230             : 
     231           0 :     OTable* pTable = new OTable(m_pTables,isCaseSensitive(),m_Name,m_Type,m_Description,m_SchemaName,m_CatalogName);
     232           0 :     pTable->setNew(true);
     233           0 :     return pTable;
     234             : }
     235             : 
     236             : // XIndexesSupplier
     237           0 : Reference< XNameAccess > SAL_CALL OTable::getIndexes(  ) throw(RuntimeException, std::exception)
     238             : {
     239           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     240           0 :     checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
     241             : 
     242             :     try
     243             :     {
     244           0 :         if ( !m_pIndexes )
     245           0 :             refreshIndexes();
     246             :     }
     247           0 :     catch( const RuntimeException& )
     248             :     {
     249             :         // allowed to leave this method
     250           0 :         throw;
     251             :     }
     252           0 :     catch( const Exception& )
     253             :     {
     254             :         // allowed
     255             :     }
     256             : 
     257           0 :     return m_pIndexes;
     258             : }
     259             : 
     260             : // XRename
     261           0 : void SAL_CALL OTable::rename( const OUString& newName ) throw(SQLException, ElementExistException, RuntimeException, std::exception)
     262             : {
     263           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     264           0 :     checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
     265             : 
     266           0 :     const OUString sOldComposedName = getName();
     267           0 :     const Reference< XDatabaseMetaData> xMetaData = getMetaData();
     268           0 :     if ( xMetaData.is() )
     269           0 :         ::dbtools::qualifiedNameComponents(xMetaData,newName,m_CatalogName,m_SchemaName,m_Name,::dbtools::eInDataManipulation);
     270             :     else
     271           0 :         m_Name = newName;
     272             : 
     273           0 :     m_pTables->renameObject(sOldComposedName,newName);
     274           0 : }
     275             : 
     276           0 : Reference< XDatabaseMetaData> OTable::getMetaData() const
     277             : {
     278           0 :     return NULL;
     279             : }
     280             : 
     281             : // XAlterTable
     282           0 : void SAL_CALL OTable::alterColumnByName( const OUString& /*colName*/, const Reference< XPropertySet >& /*descriptor*/ ) throw(SQLException, NoSuchElementException, RuntimeException, std::exception)
     283             : {
     284           0 :     throwFeatureNotImplementedException( "XAlterTable::alterColumnByName", *this );
     285           0 : }
     286             : 
     287           0 : void SAL_CALL OTable::alterColumnByIndex( sal_Int32 /*index*/, const Reference< XPropertySet >& /*descriptor*/ ) throw(SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, RuntimeException, std::exception)
     288             : {
     289           0 :     throwFeatureNotImplementedException( "XAlterTable::alterColumnByIndex", *this );
     290           0 : }
     291             : 
     292           0 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OTable::getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     293             : {
     294           0 :     return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
     295             : }
     296             : 
     297           0 : OUString SAL_CALL OTable::getName() throw(::com::sun::star::uno::RuntimeException, std::exception)
     298             : {
     299             :     // this is only correct for tables who haven't a schema or catalog name
     300             :     OSL_ENSURE(m_CatalogName.isEmpty(),"getName(): forgot to overload getName()!");
     301             :     OSL_ENSURE(m_SchemaName.isEmpty(),"getName(): forgot to overload getName()!");
     302           0 :     return m_Name;
     303             : }
     304             : 
     305           0 : void SAL_CALL OTable::setName( const OUString& /*aName*/ ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     306             : {
     307           0 : }
     308             : 
     309           0 : void OTable::refreshColumns()
     310             : {
     311           0 : }
     312             : 
     313           0 : void OTable::refreshKeys()
     314             : {
     315           0 : }
     316             : 
     317           0 : void OTable::refreshIndexes()
     318             : {
     319           0 : }
     320             : 
     321             : 
     322             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10