LCOV - code coverage report
Current view: top level - connectivity/source/drivers/file - FTable.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 48 90 53.3 %
Date: 2014-04-11 Functions: 9 21 42.9 %
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             : 
      21             : #include <stdio.h>
      22             : #include "file/FTable.hxx"
      23             : #include "file/FColumns.hxx"
      24             : #include <com/sun/star/sdbc/XRow.hpp>
      25             : #include <com/sun/star/sdbc/XResultSet.hpp>
      26             : #include <cppuhelper/typeprovider.hxx>
      27             : #include <com/sun/star/lang/DisposedException.hpp>
      28             : #include <com/sun/star/sdbc/ColumnValue.hpp>
      29             : #include <unotools/ucbstreamhelper.hxx>
      30             : #include <tools/debug.hxx>
      31             : 
      32             : using namespace connectivity;
      33             : using namespace connectivity::file;
      34             : using namespace ::com::sun::star::uno;
      35             : using namespace ::com::sun::star::beans;
      36             : using namespace ::com::sun::star::sdbcx;
      37             : using namespace ::com::sun::star::sdbc;
      38             : using namespace ::com::sun::star::container;
      39             : 
      40           0 : OFileTable::OFileTable(sdbcx::OCollection* _pTables,OConnection* _pConnection)
      41           0 : : OTable_TYPEDEF(_pTables,_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers())
      42             :                 ,m_pConnection(_pConnection)
      43             :                 ,m_pFileStream(NULL)
      44             :                 ,m_nFilePos(0)
      45             :                 ,m_pBuffer(NULL)
      46             :                 ,m_nBufferSize(0)
      47           0 :                 ,m_bWriteable(sal_False)
      48             : {
      49             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileTable::OFileTable" );
      50           0 :     construct();
      51           0 :     m_aColumns = new OSQLColumns();
      52           0 : }
      53             : 
      54          15 : OFileTable::OFileTable( sdbcx::OCollection* _pTables,OConnection* _pConnection,
      55             :                         const OUString& _Name,
      56             :                         const OUString& _Type,
      57             :                         const OUString& _Description ,
      58             :                         const OUString& _SchemaName,
      59             :                         const OUString& _CatalogName )
      60          30 :     : OTable_TYPEDEF(_pTables,_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers(),
      61             :                      _Name,
      62             :                      _Type,
      63             :                      _Description,
      64             :                      _SchemaName,
      65             :                      _CatalogName)
      66             :     , m_pConnection(_pConnection)
      67             :     , m_pFileStream(NULL)
      68             :     , m_nFilePos(0)
      69             :     , m_pBuffer(NULL)
      70             :     , m_nBufferSize(0)
      71          30 :     , m_bWriteable(sal_False)
      72             : {
      73             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileTable::OFileTable" );
      74          15 :     m_aColumns = new OSQLColumns();
      75          15 :     construct();
      76             :     //  refreshColumns();
      77          15 : }
      78             : 
      79          15 : OFileTable::~OFileTable( )
      80             : {
      81          15 : }
      82             : 
      83           0 : void OFileTable::refreshColumns()
      84             : {
      85             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileTable::refreshColumns" );
      86           0 :     TStringVector aVector;
      87           0 :     Reference< XResultSet > xResult = m_pConnection->getMetaData()->getColumns(Any(),
      88           0 :                                                                                m_SchemaName,m_Name, OUString("%"));
      89             : 
      90           0 :     if(xResult.is())
      91             :     {
      92           0 :         Reference< XRow > xRow(xResult,UNO_QUERY);
      93           0 :         while(xResult->next())
      94           0 :             aVector.push_back(xRow->getString(4));
      95             :     }
      96             : 
      97           0 :     if(m_pColumns)
      98           0 :         m_pColumns->reFill(aVector);
      99             :     else
     100           0 :         m_pColumns  = new OColumns(this,m_aMutex,aVector);
     101           0 : }
     102             : 
     103           0 : void OFileTable::refreshKeys()
     104             : {
     105             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileTable::refreshKeys" );
     106           0 : }
     107             : 
     108           0 : void OFileTable::refreshIndexes()
     109             : {
     110             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileTable::refreshIndexes" );
     111           0 : }
     112             : 
     113           0 : Any SAL_CALL OFileTable::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
     114             : {
     115             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileTable::queryInterface" );
     116           0 :     if( rType == ::getCppuType((const Reference<XKeysSupplier>*)0) ||
     117           0 :         rType == ::getCppuType((const Reference<XRename>*)0) ||
     118           0 :         rType == ::getCppuType((const Reference<XAlterTable>*)0) ||
     119           0 :         rType == ::getCppuType((const Reference<XIndexesSupplier>*)0) ||
     120           0 :         rType == ::getCppuType((const Reference<XDataDescriptorFactory>*)0))
     121           0 :         return Any();
     122             : 
     123           0 :     return OTable_TYPEDEF::queryInterface(rType);
     124             : }
     125             : 
     126          15 : void SAL_CALL OFileTable::disposing(void)
     127             : {
     128             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileTable::disposing" );
     129          15 :     OTable::disposing();
     130             : 
     131          15 :     ::osl::MutexGuard aGuard(m_aMutex);
     132             : 
     133          15 :     FileClose();
     134          15 : }
     135             : 
     136         122 : Sequence< sal_Int8 > OFileTable::getUnoTunnelImplementationId()
     137             : {
     138             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileTable::getUnoTunnelImplementationId" );
     139             :     static ::cppu::OImplementationId * pId = 0;
     140         122 :     if (! pId)
     141             :     {
     142           4 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     143           4 :         if (! pId)
     144             :         {
     145           4 :             static ::cppu::OImplementationId aId;
     146           4 :             pId = &aId;
     147           4 :         }
     148             :     }
     149         122 :     return pId->getImplementationId();
     150             : }
     151             : 
     152             : // com::sun::star::lang::XUnoTunnel
     153             : 
     154          61 : sal_Int64 OFileTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException, std::exception)
     155             : {
     156             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileTable::getSomething" );
     157         244 :     return (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
     158             :                 ? reinterpret_cast< sal_Int64 >( this )
     159         244 :                 : OTable_TYPEDEF::getSomething(rId);
     160             : }
     161             : 
     162          15 : void OFileTable::FileClose()
     163             : {
     164             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileTable::FileClose" );
     165          15 :     ::osl::MutexGuard aGuard(m_aMutex);
     166             : 
     167          15 :     if (m_pFileStream && m_pFileStream->IsWritable())
     168          15 :         m_pFileStream->Flush();
     169             : 
     170          15 :     delete m_pFileStream;
     171          15 :     m_pFileStream = NULL;
     172             : 
     173          15 :     if (m_pBuffer)
     174             :     {
     175          15 :         delete[] m_pBuffer;
     176          15 :         m_pBuffer = NULL;
     177          15 :     }
     178          15 : }
     179             : 
     180       11166 : void SAL_CALL OFileTable::acquire() throw()
     181             : {
     182       11166 :     OTable_TYPEDEF::acquire();
     183       11166 : }
     184             : 
     185       11166 : void SAL_CALL OFileTable::release() throw()
     186             : {
     187       11166 :     OTable_TYPEDEF::release();
     188       11166 : }
     189             : 
     190           0 : sal_Bool OFileTable::InsertRow(OValueRefVector& /*rRow*/, sal_Bool /*bFlush*/,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& /*_xCols*/)
     191             : {
     192             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileTable::InsertRow" );
     193           0 :     return sal_False;
     194             : }
     195             : 
     196           0 : sal_Bool OFileTable::DeleteRow(const OSQLColumns& /*_rCols*/)
     197             : {
     198             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileTable::DeleteRow" );
     199           0 :     return sal_False;
     200             : }
     201             : 
     202           0 : sal_Bool OFileTable::UpdateRow(OValueRefVector& /*rRow*/, OValueRefRow& /*pOrgRow*/,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& /*_xCols*/)
     203             : {
     204             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileTable::UpdateRow" );
     205           0 :     return sal_False;
     206             : }
     207             : 
     208           0 : void OFileTable::addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& /*descriptor*/)
     209             : {
     210             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileTable::addColumn" );
     211             :     OSL_FAIL( "OFileTable::addColumn: not implemented!" );
     212           0 : }
     213             : 
     214           0 : void OFileTable::dropColumn(sal_Int32 /*_nPos*/)
     215             : {
     216             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileTable::dropColumn" );
     217             :     OSL_FAIL( "OFileTable::addColumn: not implemented!" );
     218           0 : }
     219             : 
     220             : 
     221          38 : SvStream* OFileTable::createStream_simpleError( const OUString& _rFileName, StreamMode _eOpenMode)
     222             : {
     223             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileTable::createStream_simpleError" );
     224          38 :     utl::UcbLockBytesHandler* p_null_dummy = NULL;
     225          38 :     SvStream* pReturn = ::utl::UcbStreamHelper::CreateStream( _rFileName, _eOpenMode, (_eOpenMode & STREAM_NOCREATE) == STREAM_NOCREATE, p_null_dummy);
     226          38 :     if (pReturn && (ERRCODE_NONE != pReturn->GetErrorCode()))
     227             :     {
     228          16 :         delete pReturn;
     229          16 :         pReturn = NULL;
     230             :     }
     231          38 :     return pReturn;
     232             : }
     233             : 
     234             : 
     235           0 : void OFileTable::refreshHeader()
     236             : {
     237             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileTable::refreshHeader" );
     238           0 : }
     239             : 
     240             : 
     241             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10