LCOV - code coverage report
Current view: top level - libreoffice/connectivity/source/drivers/dbase - DIndexes.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 45 0.0 %
Date: 2012-12-27 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 ::rtl::OUString& _rName)
      41             : {
      42           0 :     ::rtl::OUString sFile = m_pTable->getConnection()->getURL();
      43           0 :     sFile += OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELIMITER);
      44           0 :     sFile += _rName;
      45           0 :     sFile += ::rtl::OUString(".ndx");
      46           0 :     if ( !UCBContentHelper::Exists(sFile) )
      47             :     {
      48           0 :         const ::rtl::OUString sError( m_pTable->getConnection()->getResources().getResourceStringWithSubstitution(
      49             :                 STR_COULD_NOT_LOAD_FILE,
      50             :                 "$filename$", sFile
      51           0 :             ) );
      52           0 :         ::dbtools::throwGenericSQLException( sError, *m_pTable );
      53             :     }
      54             : 
      55           0 :     sdbcx::ObjectType xRet;
      56           0 :     SvStream* pFileStream = ::connectivity::file::OFileTable::createStream_simpleError(sFile,STREAM_READ | STREAM_NOCREATE| STREAM_SHARE_DENYWRITE);
      57           0 :     if(pFileStream)
      58             :     {
      59           0 :         pFileStream->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
      60           0 :         pFileStream->SetBufferSize(PAGE_SIZE);
      61             :         ODbaseIndex::NDXHeader aHeader;
      62             : 
      63           0 :         pFileStream->Seek(0);
      64           0 :         pFileStream->Read(&aHeader,PAGE_SIZE);
      65           0 :         delete pFileStream;
      66             : 
      67           0 :         ODbaseIndex* pIndex = new ODbaseIndex(m_pTable,aHeader,_rName);
      68           0 :         xRet = pIndex;
      69           0 :         pIndex->openIndexFile();
      70             :     }
      71             :     else
      72             :     {
      73           0 :         const ::rtl::OUString sError( m_pTable->getConnection()->getResources().getResourceStringWithSubstitution(
      74             :                 STR_COULD_NOT_LOAD_FILE,
      75             :                 "$filename$", sFile
      76           0 :              ) );
      77           0 :         ::dbtools::throwGenericSQLException( sError, *m_pTable );
      78             :     }
      79           0 :     return xRet;
      80             : }
      81             : // -------------------------------------------------------------------------
      82           0 : void ODbaseIndexes::impl_refresh(  ) throw(RuntimeException)
      83             : {
      84           0 :     if(m_pTable)
      85           0 :         m_pTable->refreshIndexes();
      86           0 : }
      87             : // -------------------------------------------------------------------------
      88           0 : Reference< XPropertySet > ODbaseIndexes::createDescriptor()
      89             : {
      90           0 :     return new ODbaseIndex(m_pTable);
      91             : }
      92             : // -------------------------------------------------------------------------
      93             : // XAppend
      94           0 : sdbcx::ObjectType ODbaseIndexes::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
      95             : {
      96           0 :     Reference<XUnoTunnel> xTunnel(descriptor,UNO_QUERY);
      97           0 :     if(xTunnel.is())
      98             :     {
      99           0 :         ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()) );
     100           0 :         if(!pIndex || !pIndex->CreateImpl())
     101           0 :             throw SQLException();
     102             :     }
     103             : 
     104           0 :     return createObject( _rForName );
     105             : }
     106             : // -------------------------------------------------------------------------
     107             : // XDrop
     108           0 : void ODbaseIndexes::dropObject(sal_Int32 _nPos,const ::rtl::OUString /*_sElementName*/)
     109             : {
     110           0 :     Reference< XUnoTunnel> xTunnel(getObject(_nPos),UNO_QUERY);
     111           0 :     if ( xTunnel.is() )
     112             :     {
     113           0 :         ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()) );
     114           0 :         if ( pIndex )
     115           0 :             pIndex->DropImpl();
     116           0 :     }
     117             : 
     118           0 : }
     119             : // -------------------------------------------------------------------------
     120             : 
     121             : 
     122             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10