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

Generated by: LCOV version 1.10