LCOV - code coverage report
Current view: top level - connectivity/source/drivers/dbase - DResultSet.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 44 97 45.4 %
Date: 2012-08-25 Functions: 12 21 57.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 34 162 21.0 %

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

Generated by: LCOV version 1.10