LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/core/api - WrappedResultSet.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 101 0.0 %
Date: 2012-12-27 Functions: 0 16 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 "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           0 : 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           0 :     OCacheSet::construct(_xDriverSet,i_sRowSetFilter);
      44           0 :     m_xUpd.set(_xDriverSet,UNO_QUERY_THROW);
      45           0 :     m_xRowLocate.set(_xDriverSet,UNO_QUERY_THROW);
      46           0 :     m_xUpdRow.set(_xDriverSet,UNO_QUERY_THROW);
      47           0 : }
      48             : 
      49           0 : Any SAL_CALL WrappedResultSet::getBookmark() throw(SQLException, RuntimeException)
      50             : {
      51             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::getBookmark" );
      52           0 :     if ( m_xRowLocate.is() )
      53             :     {
      54           0 :         return m_xRowLocate->getBookmark( );
      55             :     }
      56           0 :     return makeAny(m_xDriverSet->getRow());
      57             : }
      58             : 
      59           0 : 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           0 :     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           0 : 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           0 :     return m_xRowLocate->compareBookmarks( _first,_second );
      75             : }
      76             : 
      77           0 : sal_Bool SAL_CALL WrappedResultSet::hasOrderedBookmarks(  ) throw(SQLException, RuntimeException)
      78             : {
      79             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::hasOrderedBookmarks" );
      80           0 :     return m_xRowLocate->hasOrderedBookmarks();
      81             : }
      82             : 
      83           0 : 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           0 :     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           0 : 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           0 :     m_xUpd->moveToInsertRow();
     106           0 :     sal_Int32 i = 1;
     107           0 :     connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end();
     108           0 :     for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->get().begin()+1;aIter != aEnd;++aIter,++i)
     109             :     {
     110           0 :         aIter->setSigned(m_aSignedFlags[i-1]);
     111           0 :         updateColumn(i,m_xUpdRow,*aIter);
     112             :     }
     113           0 :     m_xUpd->insertRow();
     114           0 :     (*_rInsertRow->get().begin()) = getBookmark();
     115           0 : }
     116             : 
     117           0 : 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           0 :     sal_Int32 i = 1;
     121           0 :     connectivity::ORowVector< ORowSetValue > ::Vector::const_iterator aOrgIter = _rOrginalRow->get().begin()+1;
     122           0 :     connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end();
     123           0 :     for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->get().begin()+1;aIter != aEnd;++aIter,++i,++aOrgIter)
     124             :     {
     125           0 :         aIter->setSigned(aOrgIter->isSigned());
     126           0 :         updateColumn(i,m_xUpdRow,*aIter);
     127             :     }
     128           0 :     m_xUpd->updateRow();
     129           0 : }
     130             : 
     131           0 : 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           0 :     m_xUpd->deleteRow();
     135           0 : }
     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           0 : void WrappedResultSet::fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition)
     156             : {
     157             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::fillValueRow" );
     158           0 :     OCacheSet::fillValueRow(_rRow,_nPosition);
     159           0 : }
     160             : 
     161           0 : 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           0 :     if(_rValue.isBound() && _rValue.isModified())
     165             :     {
     166           0 :         if(_rValue.isNull())
     167           0 :             _xParameter->updateNull(nPos);
     168             :         else
     169             :         {
     170             : 
     171           0 :             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           0 :                     _xParameter->updateString(nPos,_rValue);
     180           0 :                     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           0 :                     break;
     234             :             }
     235             :         }
     236             :     }
     237           0 : }
     238             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10