LCOV - code coverage report
Current view: top level - connectivity/source/drivers/dbase - DTables.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 8 41 19.5 %
Date: 2015-06-13 12:38:46 Functions: 2 6 33.3 %
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 <sal/config.h>
      21             : 
      22             : #include <dbase/DConnection.hxx>
      23             : #include "dbase/DTables.hxx"
      24             : #include "dbase/DTable.hxx"
      25             : #include <com/sun/star/sdbc/XRow.hpp>
      26             : #include <com/sun/star/sdbc/XResultSet.hpp>
      27             : #include <com/sun/star/sdbc/ColumnValue.hpp>
      28             : #include <com/sun/star/sdbc/KeyRule.hpp>
      29             : #include <com/sun/star/sdbcx/KeyType.hpp>
      30             : #include "file/FCatalog.hxx"
      31             : #include "file/FConnection.hxx"
      32             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      33             : #include "dbase/DCatalog.hxx"
      34             : #include <comphelper/types.hxx>
      35             : #include "resource/dbase_res.hrc"
      36             : #include <connectivity/dbexception.hxx>
      37             : 
      38             : using namespace ::comphelper;
      39             : using namespace connectivity;
      40             : using namespace connectivity::dbase;
      41             : using namespace connectivity::file;
      42             : using namespace ::com::sun::star::uno;
      43             : using namespace ::com::sun::star::beans;
      44             : using namespace ::com::sun::star::sdbcx;
      45             : using namespace ::com::sun::star::sdbc;
      46             : using namespace ::com::sun::star::lang;
      47             : using namespace ::com::sun::star::container;
      48             : 
      49          15 : sdbcx::ObjectType ODbaseTables::createObject(const OUString& _rName)
      50             : {
      51          15 :     ODbaseTable* pRet = new ODbaseTable(this, static_cast<ODbaseConnection*>(static_cast<OFileCatalog&>(m_rParent).getConnection()),
      52          15 :                                         _rName,OUString("TABLE"));
      53             : 
      54          15 :     sdbcx::ObjectType xRet = pRet;
      55          15 :     pRet->construct();
      56          15 :     return xRet;
      57             : }
      58             : 
      59           0 : void ODbaseTables::impl_refresh(  ) throw(RuntimeException)
      60             : {
      61           0 :     static_cast<ODbaseCatalog*>(&m_rParent)->refreshTables();
      62           0 : }
      63             : 
      64           0 : Reference< XPropertySet > ODbaseTables::createDescriptor()
      65             : {
      66           0 :     return new ODbaseTable(this, static_cast<ODbaseConnection*>(static_cast<OFileCatalog&>(m_rParent).getConnection()));
      67             : }
      68             : 
      69             : // XAppend
      70           0 : sdbcx::ObjectType ODbaseTables::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
      71             : {
      72           0 :     Reference<XUnoTunnel> xTunnel(descriptor,UNO_QUERY);
      73           0 :     if(xTunnel.is())
      74             :     {
      75           0 :         ODbaseTable* pTable = reinterpret_cast< ODbaseTable* >( xTunnel->getSomething(ODbaseTable::getUnoTunnelImplementationId()) );
      76           0 :         if(pTable)
      77             :         {
      78           0 :             pTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(_rForName));
      79             :             try
      80             :             {
      81           0 :                 if(!pTable->CreateImpl())
      82           0 :                     throw SQLException();
      83             :             }
      84           0 :             catch(SQLException&)
      85             :             {
      86           0 :                 throw;
      87             :             }
      88           0 :             catch(Exception&)
      89             :             {
      90           0 :                 throw SQLException();
      91             :             }
      92             :         }
      93             :     }
      94           0 :     return createObject( _rForName );
      95             : }
      96             : 
      97             : // XDrop
      98           0 : void ODbaseTables::dropObject(sal_Int32 _nPos, const OUString& _sElementName)
      99             : {
     100           0 :     Reference< XUnoTunnel> xTunnel;
     101             :     try
     102             :     {
     103           0 :         xTunnel.set(getObject(_nPos),UNO_QUERY);
     104             :     }
     105           0 :     catch(const Exception&)
     106             :     {
     107           0 :         if(ODbaseTable::Drop_Static(ODbaseTable::getEntry(static_cast<OFileCatalog&>(m_rParent).getConnection(),_sElementName),false,NULL))
     108           0 :             return;
     109           0 :     }
     110             : 
     111           0 :     if ( xTunnel.is() )
     112             :     {
     113           0 :         ODbaseTable* pTable = reinterpret_cast< ODbaseTable* >( xTunnel->getSomething(ODbaseTable::getUnoTunnelImplementationId()) );
     114           0 :         if(pTable)
     115           0 :             pTable->DropImpl();
     116             :     }
     117             :     else
     118             :     {
     119           0 :         const OUString sError( static_cast<OFileCatalog&>(m_rParent).getConnection()->getResources().getResourceStringWithSubstitution(
     120             :                     STR_TABLE_NOT_DROP,
     121             :                     "$tablename$", _sElementName
     122           0 :                  ) );
     123           0 :         ::dbtools::throwGenericSQLException( sError, NULL );
     124           0 :     }
     125             : }
     126             : 
     127          52 : Any SAL_CALL ODbaseTables::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
     128             : {
     129             :     typedef sdbcx::OCollection OTables_BASE;
     130          52 :     return OTables_BASE::queryInterface(rType);
     131             : }
     132             : 
     133             : 
     134             : 
     135             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11