LCOV - code coverage report
Current view: top level - dbaccess/source/core/api - WrappedResultSet.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 51 101 50.5 %
Date: 2012-08-25 Functions: 11 16 68.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 42 121 34.7 %

           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 "WrappedResultSet.hxx"
      21                 :            : #include "core_resource.hxx"
      22                 :            : #include "core_resource.hrc"
      23                 :            : #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
      24                 :            : #include <connectivity/dbexception.hxx>
      25                 :            : #include <rtl/logfile.hxx>
      26                 :            : 
      27                 :            : #include <limits>
      28                 :            : 
      29                 :            : using namespace dbaccess;
      30                 :            : using namespace ::connectivity;
      31                 :            : using namespace ::dbtools;
      32                 :            : using namespace ::com::sun::star::uno;
      33                 :            : using namespace ::com::sun::star::beans;
      34                 :            : using namespace ::com::sun::star::sdbc;
      35                 :            : using namespace ::com::sun::star::sdbcx;
      36                 :            : using namespace ::com::sun::star::container;
      37                 :            : using namespace ::com::sun::star::lang;
      38                 :            : using namespace ::osl;
      39                 :            : 
      40                 :         40 : void WrappedResultSet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter)
      41                 :            : {
      42                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::construct" );
      43                 :         40 :     OCacheSet::construct(_xDriverSet,i_sRowSetFilter);
      44                 :         40 :     m_xUpd.set(_xDriverSet,UNO_QUERY_THROW);
      45                 :         40 :     m_xRowLocate.set(_xDriverSet,UNO_QUERY_THROW);
      46                 :         40 :     m_xUpdRow.set(_xDriverSet,UNO_QUERY_THROW);
      47                 :         40 : }
      48                 :            : 
      49                 :        310 : Any SAL_CALL WrappedResultSet::getBookmark() throw(SQLException, RuntimeException)
      50                 :            : {
      51                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::getBookmark" );
      52         [ +  - ]:        310 :     if ( m_xRowLocate.is() )
      53                 :            :     {
      54                 :        310 :         return m_xRowLocate->getBookmark( );
      55                 :            :     }
      56         [ #  # ]:        310 :     return makeAny(m_xDriverSet->getRow());
      57                 :            : }
      58                 :            : 
      59                 :        398 : sal_Bool SAL_CALL WrappedResultSet::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
      60                 :            : {
      61                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::moveToBookmark" );
      62                 :        398 :     return m_xRowLocate->moveToBookmark( bookmark );
      63                 :            : }
      64                 :            : 
      65                 :          0 : sal_Bool SAL_CALL WrappedResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException)
      66                 :            : {
      67                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::moveRelativeToBookmark" );
      68                 :          0 :     return m_xRowLocate->moveRelativeToBookmark( bookmark,rows );
      69                 :            : }
      70                 :            : 
      71                 :         68 : sal_Int32 SAL_CALL WrappedResultSet::compareBookmarks( const Any& _first, const Any& _second ) throw(SQLException, RuntimeException)
      72                 :            : {
      73                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::compareBookmarks" );
      74                 :         68 :     return m_xRowLocate->compareBookmarks( _first,_second );
      75                 :            : }
      76                 :            : 
      77                 :          2 : sal_Bool SAL_CALL WrappedResultSet::hasOrderedBookmarks(  ) throw(SQLException, RuntimeException)
      78                 :            : {
      79                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::hasOrderedBookmarks" );
      80                 :          2 :     return m_xRowLocate->hasOrderedBookmarks();
      81                 :            : }
      82                 :            : 
      83                 :          4 : sal_Int32 SAL_CALL WrappedResultSet::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
      84                 :            : {
      85                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::hashBookmark" );
      86                 :          4 :     return m_xRowLocate->hashBookmark(bookmark);
      87                 :            : }
      88                 :            : 
      89                 :            : // ::com::sun::star::sdbcx::XDeleteRows
      90                 :          0 : Sequence< sal_Int32 > SAL_CALL WrappedResultSet::deleteRows( const Sequence< Any >& rows ,const connectivity::OSQLTable& /*_xTable*/) throw(SQLException, RuntimeException)
      91                 :            : {
      92                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::deleteRows" );
      93         [ #  # ]:          0 :     Reference< ::com::sun::star::sdbcx::XDeleteRows> xDeleteRow(m_xRowLocate,UNO_QUERY);
      94         [ #  # ]:          0 :     if(xDeleteRow.is())
      95                 :            :     {
      96 [ #  # ][ #  # ]:          0 :         return xDeleteRow->deleteRows(rows);
      97                 :            :     }
      98         [ #  # ]:          0 :     return Sequence< sal_Int32 >();
      99                 :            : }
     100                 :            : 
     101                 :          2 : void SAL_CALL WrappedResultSet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& /*_xTable*/ ) throw(SQLException, RuntimeException)
     102                 :            : {
     103                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::insertRow" );
     104                 :            : 
     105 [ +  - ][ +  - ]:          2 :     m_xUpd->moveToInsertRow();
     106                 :          2 :     sal_Int32 i = 1;
     107                 :          2 :     connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end();
     108 [ +  - ][ +  - ]:         64 :     for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->get().begin()+1;aIter != aEnd;++aIter,++i)
         [ +  + ][ +  - ]
     109                 :            :     {
     110 [ +  - ][ +  - ]:         62 :         aIter->setSigned(m_aSignedFlags[i-1]);
                 [ +  - ]
     111 [ +  - ][ +  - ]:         62 :         updateColumn(i,m_xUpdRow,*aIter);
     112                 :            :     }
     113 [ +  - ][ +  - ]:          2 :     m_xUpd->insertRow();
     114 [ +  - ][ +  - ]:          2 :     (*_rInsertRow->get().begin()) = getBookmark();
                 [ +  - ]
     115                 :          2 : }
     116                 :            : 
     117                 :          8 : void SAL_CALL WrappedResultSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& /*_xTable*/  ) throw(SQLException, RuntimeException)
     118                 :            : {
     119                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::updateRow" );
     120                 :          8 :     sal_Int32 i = 1;
     121 [ +  - ][ +  - ]:          8 :     connectivity::ORowVector< ORowSetValue > ::Vector::const_iterator aOrgIter = _rOrginalRow->get().begin()+1;
     122                 :          8 :     connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end();
     123 [ +  - ][ +  - ]:         56 :     for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->get().begin()+1;aIter != aEnd;++aIter,++i,++aOrgIter)
         [ +  - ][ +  + ]
                 [ +  - ]
     124                 :            :     {
     125 [ +  - ][ +  - ]:         48 :         aIter->setSigned(aOrgIter->isSigned());
                 [ +  - ]
     126 [ +  - ][ +  - ]:         48 :         updateColumn(i,m_xUpdRow,*aIter);
     127                 :            :     }
     128 [ +  - ][ +  - ]:          8 :     m_xUpd->updateRow();
     129                 :          8 : }
     130                 :            : 
     131                 :          2 : void SAL_CALL WrappedResultSet::deleteRow(const ORowSetRow& /*_rDeleteRow*/ ,const connectivity::OSQLTable& /*_xTable*/  ) throw(SQLException, RuntimeException)
     132                 :            : {
     133                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::deleteRow" );
     134                 :          2 :     m_xUpd->deleteRow();
     135                 :          2 : }
     136                 :            : 
     137                 :          0 : void SAL_CALL WrappedResultSet::cancelRowUpdates(  ) throw(SQLException, RuntimeException)
     138                 :            : {
     139                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::cancelRowUpdates" );
     140                 :          0 :     m_xUpd->cancelRowUpdates();
     141                 :          0 : }
     142                 :            : 
     143                 :          0 : void SAL_CALL WrappedResultSet::moveToInsertRow(  ) throw(SQLException, RuntimeException)
     144                 :            : {
     145                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::moveToInsertRow" );
     146                 :          0 :     m_xUpd->moveToInsertRow();
     147                 :          0 : }
     148                 :            : 
     149                 :          0 : void SAL_CALL WrappedResultSet::moveToCurrentRow(  ) throw(SQLException, RuntimeException)
     150                 :            : {
     151                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::moveToCurrentRow" );
     152                 :          0 :     m_xUpd->moveToCurrentRow();
     153                 :          0 : }
     154                 :            : 
     155                 :        308 : void WrappedResultSet::fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition)
     156                 :            : {
     157                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::fillValueRow" );
     158                 :        308 :     OCacheSet::fillValueRow(_rRow,_nPosition);
     159                 :        308 : }
     160                 :            : 
     161                 :        110 : void WrappedResultSet::updateColumn(sal_Int32 nPos,Reference< XRowUpdate > _xParameter,const ORowSetValue& _rValue)
     162                 :            : {
     163                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::updateColumn" );
     164 [ +  + ][ +  + ]:        110 :     if(_rValue.isBound() && _rValue.isModified())
                 [ +  + ]
     165                 :            :     {
     166         [ -  + ]:         10 :         if(_rValue.isNull())
     167                 :          0 :             _xParameter->updateNull(nPos);
     168                 :            :         else
     169                 :            :         {
     170                 :            : 
     171   [ -  +  -  -  :         10 :             switch(_rValue.getTypeKind())
          -  -  -  -  -  
          -  -  -  -  -  
                      - ]
     172                 :            :             {
     173                 :            :                 case DataType::DECIMAL:
     174                 :            :                 case DataType::NUMERIC:
     175         [ #  # ]:          0 :                     _xParameter->updateNumericObject(nPos,_rValue.makeAny(),m_xSetMetaData->getScale(nPos));
     176                 :          0 :                     break;
     177                 :            :                 case DataType::CHAR:
     178                 :            :                 case DataType::VARCHAR:
     179         [ +  - ]:         10 :                     _xParameter->updateString(nPos,_rValue);
     180                 :         10 :                     break;
     181                 :            :                 case DataType::BIGINT:
     182         [ #  # ]:          0 :                     if ( _rValue.isSigned() )
     183                 :          0 :                         _xParameter->updateLong(nPos,_rValue);
     184                 :            :                     else
     185         [ #  # ]:          0 :                         _xParameter->updateString(nPos,_rValue);
     186                 :          0 :                     break;
     187                 :            :                 case DataType::BIT:
     188                 :            :                 case DataType::BOOLEAN:
     189                 :          0 :                     _xParameter->updateBoolean(nPos,_rValue);
     190                 :          0 :                     break;
     191                 :            :                 case DataType::TINYINT:
     192         [ #  # ]:          0 :                     if ( _rValue.isSigned() )
     193                 :          0 :                         _xParameter->updateByte(nPos,_rValue);
     194                 :            :                     else
     195                 :          0 :                         _xParameter->updateShort(nPos,_rValue);
     196                 :          0 :                     break;
     197                 :            :                 case DataType::SMALLINT:
     198         [ #  # ]:          0 :                     if ( _rValue.isSigned() )
     199                 :          0 :                         _xParameter->updateShort(nPos,_rValue);
     200                 :            :                     else
     201                 :          0 :                         _xParameter->updateInt(nPos,_rValue);
     202                 :          0 :                     break;
     203                 :            :                 case DataType::INTEGER:
     204         [ #  # ]:          0 :                     if ( _rValue.isSigned() )
     205                 :          0 :                         _xParameter->updateInt(nPos,_rValue);
     206                 :            :                     else
     207                 :          0 :                         _xParameter->updateLong(nPos,_rValue);
     208                 :          0 :                     break;
     209                 :            :                 case DataType::FLOAT:
     210                 :          0 :                     _xParameter->updateFloat(nPos,_rValue);
     211                 :          0 :                     break;
     212                 :            :                 case DataType::DOUBLE:
     213                 :            :                 case DataType::REAL:
     214                 :          0 :                     _xParameter->updateDouble(nPos,_rValue);
     215                 :          0 :                     break;
     216                 :            :                 case DataType::DATE:
     217         [ #  # ]:          0 :                     _xParameter->updateDate(nPos,_rValue);
     218                 :          0 :                     break;
     219                 :            :                 case DataType::TIME:
     220         [ #  # ]:          0 :                     _xParameter->updateTime(nPos,_rValue);
     221                 :          0 :                     break;
     222                 :            :                 case DataType::TIMESTAMP:
     223         [ #  # ]:          0 :                     _xParameter->updateTimestamp(nPos,_rValue);
     224                 :          0 :                     break;
     225                 :            :                 case DataType::BINARY:
     226                 :            :                 case DataType::VARBINARY:
     227                 :            :                 case DataType::LONGVARBINARY:
     228         [ #  # ]:          0 :                     _xParameter->updateBytes(nPos,_rValue);
     229                 :          0 :                     break;
     230                 :            :                 case DataType::BLOB:
     231                 :            :                 case DataType::CLOB:
     232         [ #  # ]:          0 :                     _xParameter->updateObject(nPos,_rValue.getAny());
     233                 :         10 :                     break;
     234                 :            :             }
     235                 :            :         }
     236                 :            :     }
     237                 :        110 : }
     238                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10