LCOV - code coverage report
Current view: top level - connectivity/source/drivers/dbase - DIndexes.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 44 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 5 0.0 %
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/DIndexes.hxx"
      21             : #include "dbase/DIndex.hxx"
      22             : #include <connectivity/dbexception.hxx>
      23             : #include <unotools/ucbhelper.hxx>
      24             : #include <comphelper/types.hxx>
      25             : #include "resource/dbase_res.hrc"
      26             : 
      27             : using namespace ::comphelper;
      28             : 
      29             : using namespace utl;
      30             : using namespace ::connectivity;
      31             : using namespace ::dbtools;
      32             : using namespace ::connectivity::dbase;
      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             : using namespace ::com::sun::star::lang;
      39             : 
      40           0 : sdbcx::ObjectType ODbaseIndexes::createObject(const OUString& _rName)
      41             : {
      42           0 :     OUString sFile = m_pTable->getConnection()->getURL() +
      43           0 :         OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELIMITER) +
      44           0 :         _rName + ".ndx";
      45           0 :     if ( !UCBContentHelper::Exists(sFile) )
      46             :     {
      47           0 :         const OUString sError( m_pTable->getConnection()->getResources().getResourceStringWithSubstitution(
      48             :                 STR_COULD_NOT_LOAD_FILE,
      49             :                 "$filename$", sFile
      50           0 :             ) );
      51           0 :         ::dbtools::throwGenericSQLException( sError, *m_pTable );
      52             :     }
      53             : 
      54           0 :     sdbcx::ObjectType xRet;
      55           0 :     SvStream* pFileStream = ::connectivity::file::OFileTable::createStream_simpleError(sFile, StreamMode::READ | StreamMode::NOCREATE | StreamMode::SHARE_DENYWRITE);
      56           0 :     if(pFileStream)
      57             :     {
      58           0 :         pFileStream->SetEndian(SvStreamEndian::LITTLE);
      59           0 :         pFileStream->SetBufferSize(DINDEX_PAGE_SIZE);
      60             :         ODbaseIndex::NDXHeader aHeader;
      61             : 
      62           0 :         pFileStream->Seek(0);
      63           0 :         pFileStream->Read(&aHeader,DINDEX_PAGE_SIZE);
      64           0 :         delete pFileStream;
      65             : 
      66           0 :         ODbaseIndex* pIndex = new ODbaseIndex(m_pTable,aHeader,_rName);
      67           0 :         xRet = pIndex;
      68           0 :         pIndex->openIndexFile();
      69             :     }
      70             :     else
      71             :     {
      72           0 :         const OUString sError( m_pTable->getConnection()->getResources().getResourceStringWithSubstitution(
      73             :                 STR_COULD_NOT_LOAD_FILE,
      74             :                 "$filename$", sFile
      75           0 :              ) );
      76           0 :         ::dbtools::throwGenericSQLException( sError, *m_pTable );
      77             :     }
      78           0 :     return xRet;
      79             : }
      80             : 
      81           0 : void ODbaseIndexes::impl_refresh(  ) throw(RuntimeException)
      82             : {
      83           0 :     if(m_pTable)
      84           0 :         m_pTable->refreshIndexes();
      85           0 : }
      86             : 
      87           0 : Reference< XPropertySet > ODbaseIndexes::createDescriptor()
      88             : {
      89           0 :     return new ODbaseIndex(m_pTable);
      90             : }
      91             : 
      92             : // XAppend
      93           0 : sdbcx::ObjectType ODbaseIndexes::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
      94             : {
      95           0 :     Reference<XUnoTunnel> xTunnel(descriptor,UNO_QUERY);
      96           0 :     if(xTunnel.is())
      97             :     {
      98           0 :         ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()) );
      99           0 :         if(!pIndex || !pIndex->CreateImpl())
     100           0 :             throw SQLException();
     101             :     }
     102             : 
     103           0 :     return createObject( _rForName );
     104             : }
     105             : 
     106             : // XDrop
     107           0 : void ODbaseIndexes::dropObject(sal_Int32 _nPos, const OUString& /*_sElementName*/)
     108             : {
     109           0 :     Reference< XUnoTunnel> xTunnel(getObject(_nPos),UNO_QUERY);
     110           0 :     if ( xTunnel.is() )
     111             :     {
     112           0 :         ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()) );
     113           0 :         if ( pIndex )
     114           0 :             pIndex->DropImpl();
     115           0 :     }
     116             : 
     117           0 : }
     118             : 
     119             : 
     120             : 
     121             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11