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

Generated by: LCOV version 1.11