LCOV - code coverage report
Current view: top level - connectivity/source/drivers/dbase - DResultSet.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 44 92 47.8 %
Date: 2014-11-03 Functions: 12 21 57.1 %
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 <com/sun/star/sdbcx/CompareBookmark.hpp>
      21             : #include "dbase/DResultSet.hxx"
      22             : #include <com/sun/star/lang/DisposedException.hpp>
      23             : #include <comphelper/sequence.hxx>
      24             : #include <cppuhelper/supportsservice.hxx>
      25             : #include "dbase/DIndex.hxx"
      26             : #include "dbase/DIndexIter.hxx"
      27             : #include "dbase/DCode.hxx"
      28             : #include <comphelper/types.hxx>
      29             : #include <connectivity/dbexception.hxx>
      30             : #include "resource/dbase_res.hrc"
      31             : 
      32             : using namespace ::comphelper;
      33             : 
      34             : using namespace connectivity::dbase;
      35             : using namespace connectivity::file;
      36             : using namespace ::cppu;
      37             : using namespace com::sun::star::uno;
      38             : using namespace com::sun::star::lang;
      39             : using namespace com::sun::star::beans;
      40             : using namespace com::sun::star::sdbc;
      41             : using namespace com::sun::star::sdbcx;
      42             : 
      43          42 : ODbaseResultSet::ODbaseResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator&   _aSQLIterator)
      44             :                 : file::OResultSet(pStmt,_aSQLIterator)
      45          42 :                 ,m_bBookmarkable(true)
      46             : {
      47          42 :     registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE),         PROPERTY_ID_ISBOOKMARKABLE,       PropertyAttribute::READONLY,&m_bBookmarkable,                ::getBooleanCppuType());
      48          42 : }
      49             : 
      50           0 : OUString SAL_CALL ODbaseResultSet::getImplementationName(  ) throw ( RuntimeException, std::exception)
      51             : {
      52           0 :     return OUString("com.sun.star.sdbcx.dbase.ResultSet");
      53             : }
      54             : 
      55           0 : Sequence< OUString > SAL_CALL ODbaseResultSet::getSupportedServiceNames(  ) throw( RuntimeException, std::exception)
      56             : {
      57           0 :      Sequence< OUString > aSupported(2);
      58           0 :     aSupported[0] = "com.sun.star.sdbc.ResultSet";
      59           0 :     aSupported[1] = "com.sun.star.sdbcx.ResultSet";
      60           0 :     return aSupported;
      61             : }
      62             : 
      63           0 : sal_Bool SAL_CALL ODbaseResultSet::supportsService( const OUString& _rServiceName ) throw( RuntimeException, std::exception)
      64             : {
      65           0 :     return cppu::supportsService(this, _rServiceName);
      66             : }
      67             : 
      68        1104 : Any SAL_CALL ODbaseResultSet::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
      69             : {
      70        1104 :     Any aRet = ODbaseResultSet_BASE::queryInterface(rType);
      71        1104 :     return aRet.hasValue() ? aRet : OResultSet::queryInterface(rType);
      72             : }
      73             : 
      74           0 :  Sequence<  Type > SAL_CALL ODbaseResultSet::getTypes(  ) throw( RuntimeException, std::exception)
      75             : {
      76           0 :     return ::comphelper::concatSequences(OResultSet::getTypes(),ODbaseResultSet_BASE::getTypes());
      77             : }
      78             : 
      79             : 
      80             : // XRowLocate
      81         350 : Any SAL_CALL ODbaseResultSet::getBookmark(  ) throw( SQLException,  RuntimeException, std::exception)
      82             : {
      83         350 :      ::osl::MutexGuard aGuard( m_aMutex );
      84         350 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
      85             :     OSL_ENSURE((m_bShowDeleted || !m_aRow->isDeleted()),"getBookmark called for deleted row");
      86             : 
      87         350 :     return makeAny((sal_Int32)(m_aRow->get())[0]->getValue());
      88             : }
      89             : 
      90          32 : sal_Bool SAL_CALL ODbaseResultSet::moveToBookmark( const  Any& bookmark ) throw( SQLException,  RuntimeException, std::exception)
      91             : {
      92          32 :     ::osl::MutexGuard aGuard( m_aMutex );
      93          32 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
      94             : 
      95             : 
      96          32 :     m_bRowDeleted = m_bRowInserted = m_bRowUpdated = false;
      97             : 
      98          32 :     return m_pTable ? Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),true) : sal_False;
      99             : }
     100             : 
     101           0 : sal_Bool SAL_CALL ODbaseResultSet::moveRelativeToBookmark( const  Any& bookmark, sal_Int32 rows ) throw( SQLException,  RuntimeException, std::exception)
     102             : {
     103           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     104           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     105           0 :     if(!m_pTable)
     106           0 :         return sal_False;
     107             : 
     108             : 
     109           0 :     Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),false);
     110             : 
     111           0 :     return relative(rows);
     112             : }
     113             : 
     114             : 
     115         248 : sal_Int32 SAL_CALL ODbaseResultSet::compareBookmarks( const Any& lhs, const Any& rhs ) throw( SQLException,  RuntimeException, std::exception)
     116             : {
     117         248 :     sal_Int32 nFirst(0),nSecond(0),nResult(0);
     118         248 :     if ( !( lhs  >>= nFirst ) || !( rhs >>= nSecond ) )
     119             :     {
     120           0 :         ::connectivity::SharedResources aResources;
     121           0 :         const OUString sMessage = aResources.getResourceString(STR_INVALID_BOOKMARK);
     122           0 :         ::dbtools::throwGenericSQLException(sMessage ,*this);
     123             :     } // if ( !( lhs  >>= nFirst ) || !( rhs >>= nSecond ) )
     124             : 
     125             :     // have a look at CompareBookmark
     126             :     // we can't use the names there because we already have defines with the same name from the parser
     127         248 :     if(nFirst < nSecond)
     128           2 :         nResult = -1;
     129         246 :     else if(nFirst > nSecond)
     130           0 :         nResult = 1;
     131             :     else
     132         246 :         nResult = 0;
     133             : 
     134         248 :     return  nResult;
     135             : }
     136             : 
     137           2 : sal_Bool SAL_CALL ODbaseResultSet::hasOrderedBookmarks(  ) throw( SQLException,  RuntimeException, std::exception)
     138             : {
     139           2 :     return sal_True;
     140             : }
     141             : 
     142           4 : sal_Int32 SAL_CALL ODbaseResultSet::hashBookmark( const  Any& bookmark ) throw( SQLException,  RuntimeException, std::exception)
     143             : {
     144           4 :     ::osl::MutexGuard aGuard( m_aMutex );
     145           4 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     146             : 
     147             : 
     148           4 :     return comphelper::getINT32(bookmark);
     149             : }
     150             : 
     151             : // XDeleteRows
     152           0 : Sequence< sal_Int32 > SAL_CALL ODbaseResultSet::deleteRows( const  Sequence<  Any >& /*rows*/ ) throw( SQLException,  RuntimeException, std::exception)
     153             : {
     154           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     155           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     156             : 
     157           0 :     ::dbtools::throwFeatureNotImplementedSQLException( "XDeleteRows::deleteRows", *this );
     158           0 :     return Sequence< sal_Int32 >();
     159             : }
     160             : 
     161           0 : bool ODbaseResultSet::fillIndexValues(const Reference< XColumnsSupplier> &_xIndex)
     162             : {
     163           0 :     Reference<XUnoTunnel> xTunnel(_xIndex,UNO_QUERY);
     164           0 :     if(xTunnel.is())
     165             :     {
     166           0 :         dbase::ODbaseIndex* pIndex = reinterpret_cast< dbase::ODbaseIndex* >( xTunnel->getSomething(dbase::ODbaseIndex::getUnoTunnelImplementationId()) );
     167           0 :         if(pIndex)
     168             :         {
     169           0 :             dbase::OIndexIterator* pIter = pIndex->createIterator(NULL,NULL);
     170             : 
     171           0 :             if (pIter)
     172             :             {
     173           0 :                 sal_uIntPtr nRec = pIter->First();
     174           0 :                 while (nRec != NODE_NOTFOUND)
     175             :                 {
     176           0 :                     if (m_aOrderbyAscending[0])
     177           0 :                         m_pFileSet->get().push_back(nRec);
     178             :                     else
     179           0 :                         m_pFileSet->get().insert(m_pFileSet->get().begin(),nRec);
     180           0 :                     nRec = pIter->Next();
     181             :                 }
     182           0 :                 m_pFileSet->setFrozen();
     183           0 :                 delete pIter;
     184           0 :                 return true;
     185             :             }
     186             :         }
     187             :     }
     188           0 :     return false;
     189             : }
     190             : 
     191         294 : ::cppu::IPropertyArrayHelper & ODbaseResultSet::getInfoHelper()
     192             : {
     193         294 :     return *ODbaseResultSet_BASE3::getArrayHelper();
     194             : }
     195             : 
     196          36 : ::cppu::IPropertyArrayHelper* ODbaseResultSet::createArrayHelper() const
     197             : {
     198          36 :     Sequence< Property > aProps;
     199          36 :     describeProperties(aProps);
     200          36 :     return new ::cppu::OPropertyArrayHelper(aProps);
     201             : }
     202             : 
     203        2382 : void SAL_CALL ODbaseResultSet::acquire() throw()
     204             : {
     205        2382 :     ODbaseResultSet_BASE2::acquire();
     206        2382 : }
     207             : 
     208        2382 : void SAL_CALL ODbaseResultSet::release() throw()
     209             : {
     210        2382 :     ODbaseResultSet_BASE2::release();
     211        2382 : }
     212             : 
     213          42 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL ODbaseResultSet::getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     214             : {
     215          42 :     return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
     216             : }
     217             : 
     218           0 : OSQLAnalyzer* ODbaseResultSet::createAnalyzer()
     219             : {
     220           0 :     return new OFILEAnalyzer(m_pTable->getConnection());
     221             : }
     222             : 
     223           0 : sal_Int32 ODbaseResultSet::getCurrentFilePos() const
     224             : {
     225           0 :     return m_pTable->getFilePos();
     226             : }
     227             : 
     228             : 
     229             : 
     230             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10