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

Generated by: LCOV version 1.10