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

Generated by: LCOV version 1.11