LCOV - code coverage report
Current view: top level - dbaccess/source/core/api - View.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 45 0.0 %
Date: 2014-04-14 Functions: 0 11 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 "View.hxx"
      21             : #include "dbastrings.hrc"
      22             : 
      23             : #include "connectivity/dbexception.hxx"
      24             : #include "connectivity/dbtools.hxx"
      25             : 
      26             : #include <com/sun/star/lang/WrappedTargetException.hpp>
      27             : #include <com/sun/star/lang/DisposedException.hpp>
      28             : #include <com/sun/star/sdbc/XRow.hpp>
      29             : 
      30             : #include <cppuhelper/exc_hlp.hxx>
      31             : #include <tools/diagnose_ex.h>
      32             : #include <unotools/sharedunocomponent.hxx>
      33             : 
      34             : namespace dbaccess
      35             : {
      36             : 
      37             :     using namespace ::com::sun::star::uno;
      38             :     using ::com::sun::star::sdbc::XDatabaseMetaData;
      39             :     using ::com::sun::star::sdbc::SQLException;
      40             :     using ::com::sun::star::sdbc::XConnection;
      41             :     using ::com::sun::star::lang::WrappedTargetException;
      42             :     using ::com::sun::star::lang::XMultiServiceFactory;
      43             :     using ::com::sun::star::sdbc::XResultSet;
      44             :     using ::com::sun::star::sdbc::XStatement;
      45             :     using ::com::sun::star::lang::DisposedException;
      46             :     using ::com::sun::star::sdbc::XRow;
      47             : 
      48           0 :     OUString lcl_getServiceNameForSetting(const Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,const OUString& i_sSetting)
      49             :     {
      50           0 :         OUString sSupportService;
      51           0 :         Any aValue;
      52           0 :         if ( dbtools::getDataSourceSetting(_xConnection,i_sSetting,aValue) )
      53             :         {
      54           0 :             aValue >>= sSupportService;
      55             :         }
      56           0 :         return sSupportService;
      57             :     }
      58             :     // View
      59           0 :     View::View( const Reference< XConnection >& _rxConnection, sal_Bool _bCaseSensitive,
      60             :         const OUString& _rCatalogName,const OUString& _rSchemaName, const OUString& _rName )
      61           0 :         :View_Base( _bCaseSensitive, _rName, _rxConnection->getMetaData(), 0, OUString(), _rSchemaName, _rCatalogName )
      62             :     {
      63           0 :         m_nCommandHandle = getProperty(PROPERTY_COMMAND).Handle;
      64             :         try
      65             :         {
      66           0 :             Reference<XMultiServiceFactory> xFac(_rxConnection,UNO_QUERY_THROW);
      67           0 :             static const OUString s_sViewAccess("ViewAccessServiceName");
      68           0 :             m_xViewAccess.set(xFac->createInstance(lcl_getServiceNameForSetting(_rxConnection,s_sViewAccess)),UNO_QUERY);
      69             :         }
      70           0 :         catch(const Exception& )
      71             :         {
      72             :             DBG_UNHANDLED_EXCEPTION();
      73             :         }
      74           0 :     }
      75             : 
      76           0 :     View::~View()
      77             :     {
      78           0 :     }
      79             : 
      80           0 :     IMPLEMENT_FORWARD_REFCOUNT( View, View_Base )
      81           0 :     IMPLEMENT_GET_IMPLEMENTATION_ID( View )
      82             : 
      83           0 :     Any SAL_CALL View::queryInterface( const Type & _rType ) throw(RuntimeException, std::exception)
      84             :     {
      85           0 :         if(_rType == getCppuType( (Reference<XAlterView>*)0) && !m_xViewAccess.is() )
      86           0 :             return Any();
      87           0 :         Any aReturn = View_Base::queryInterface( _rType );
      88           0 :         if ( !aReturn.hasValue() )
      89           0 :             aReturn = View_IBASE::queryInterface( _rType );
      90           0 :         return aReturn;
      91             :     }
      92             : 
      93           0 :     Sequence< Type > SAL_CALL View::getTypes(  ) throw(RuntimeException, std::exception)
      94             :     {
      95           0 :         Type aAlterType = getCppuType( (Reference<XAlterView>*)0);
      96             : 
      97           0 :         Sequence< Type > aTypes( ::comphelper::concatSequences(View_Base::getTypes(),View_IBASE::getTypes()) );
      98           0 :         ::std::vector<Type> aOwnTypes;
      99           0 :         aOwnTypes.reserve(aTypes.getLength());
     100             : 
     101           0 :         const Type* pIter = aTypes.getConstArray();
     102           0 :         const Type* pEnd = pIter + aTypes.getLength();
     103           0 :         for(;pIter != pEnd ;++pIter)
     104             :         {
     105           0 :             if( (*pIter != aAlterType || m_xViewAccess.is()) )
     106           0 :                 aOwnTypes.push_back(*pIter);
     107             :         }
     108             : 
     109           0 :         Type* pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
     110           0 :         return Sequence< Type >(pTypes, aOwnTypes.size());
     111             :     }
     112             : 
     113           0 :     void SAL_CALL View::alterCommand( const OUString& _rNewCommand ) throw (SQLException, RuntimeException, std::exception)
     114             :     {
     115             :         OSL_ENSURE(m_xViewAccess.is(),"Illegal call to AlterView!");
     116           0 :         m_xViewAccess->alterCommand(this,_rNewCommand);
     117           0 :     }
     118             : 
     119           0 :     void SAL_CALL View::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
     120             :     {
     121           0 :         if ( _nHandle == m_nCommandHandle && m_xViewAccess.is() )
     122             :         {
     123             :             // retrieve the very current command, don't rely on the base classes cached value
     124             :             // (which we initialized empty, anyway)
     125           0 :             _rValue <<= m_xViewAccess->getCommand(const_cast<View*>(this));
     126           0 :             return;
     127             :         }
     128             : 
     129           0 :         View_Base::getFastPropertyValue( _rValue, _nHandle );
     130             :     }
     131             : 
     132             : } // namespace dbaccess
     133             : 
     134             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10