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

Generated by: LCOV version 1.10