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

Generated by: LCOV version 1.10