LCOV - code coverage report
Current view: top level - connectivity/source/inc/odbc - OStatement.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 9 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 9 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             : #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_OSTATEMENT_HXX
      21             : #define INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_OSTATEMENT_HXX
      22             : 
      23             : #include <com/sun/star/sdbc/XStatement.hpp>
      24             : #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
      25             : #include <com/sun/star/sdbc/XMultipleResults.hpp>
      26             : #include <com/sun/star/sdbc/XBatchExecution.hpp>
      27             : #include <com/sun/star/sdbc/XCloseable.hpp>
      28             : #include <com/sun/star/sdbc/SQLWarning.hpp>
      29             : #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
      30             : #include <com/sun/star/util/XCancellable.hpp>
      31             : #include <comphelper/proparrhlp.hxx>
      32             : #include <cppuhelper/compbase6.hxx>
      33             : #include <comphelper/uno3.hxx>
      34             : #include <connectivity/CommonTools.hxx>
      35             : #include "odbc/OFunctions.hxx"
      36             : #include "odbc/OConnection.hxx"
      37             : #include "odbc/odbcbasedllapi.hxx"
      38             : #include <list>
      39             : #include <com/sun/star/lang/XServiceInfo.hpp>
      40             : #include <comphelper/broadcasthelper.hxx>
      41             : 
      42             : namespace connectivity
      43             : {
      44             :     namespace odbc
      45             :     {
      46             : 
      47             :         typedef ::cppu::WeakComponentImplHelper6<   ::com::sun::star::sdbc::XStatement,
      48             :                                                     ::com::sun::star::sdbc::XWarningsSupplier,
      49             :                                                     ::com::sun::star::util::XCancellable,
      50             :                                                     ::com::sun::star::sdbc::XCloseable,
      51             :                                                     ::com::sun::star::sdbc::XGeneratedResultSet,
      52             :                                                     ::com::sun::star::sdbc::XMultipleResults> OStatement_BASE;
      53             : 
      54             :         class OResultSet;
      55             : 
      56             :         //************ Class: java.sql.Statement
      57             : 
      58             :         class OOO_DLLPUBLIC_ODBCBASE OStatement_Base :
      59             :                                         public comphelper::OBaseMutex,
      60             :                                         public  OStatement_BASE,
      61             :                                         public  ::cppu::OPropertySetHelper,
      62             :                                         public  ::comphelper::OPropertyArrayUsageHelper<OStatement_Base>
      63             : 
      64             :         {
      65             :         ::com::sun::star::sdbc::SQLWarning                                           m_aLastWarning;
      66             :         protected:
      67             :             ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet>   m_xResultSet;   // The last ResultSet created
      68             :             ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement>       m_xGeneratedStatement;
      69             :             //  for this Statement
      70             : 
      71             :             ::std::list< OUString>   m_aBatchList;
      72             :             OUString                 m_sSqlStatement;
      73             : 
      74             :             OConnection*                    m_pConnection;// The owning Connection object
      75             :             SQLHANDLE                       m_aStatementHandle;
      76             :             SQLUSMALLINT*                   m_pRowStatusArray;
      77             :             ::cppu::OBroadcastHelper&       rBHelper;
      78             : 
      79             :         protected:
      80             : 
      81             :             sal_Int64 getQueryTimeOut()         const;
      82             :             sal_Int64 getMaxFieldSize()         const;
      83             :             sal_Int64 getMaxRows()              const;
      84             :             sal_Int32 getResultSetConcurrency() const;
      85             :             sal_Int32 getResultSetType()        const;
      86             :             sal_Int32 getFetchDirection()       const;
      87             :             sal_Int32 getFetchSize()            const;
      88             :             OUString getCursorName()     const;
      89             :             bool isUsingBookmarks()         const;
      90             :             bool getEscapeProcessing()      const;
      91             :             template < typename T, SQLINTEGER BufferLength > T getStmtOption (SQLINTEGER fOption, T dflt = 0) const;
      92             : 
      93             :             void setQueryTimeOut(sal_Int64 _par0)           ;
      94             :             void setMaxFieldSize(sal_Int64 _par0)           ;
      95             :             void setMaxRows(sal_Int64 _par0)                ;
      96             :             void setFetchDirection(sal_Int32 _par0)         ;
      97             :             void setFetchSize(sal_Int32 _par0)              ;
      98             :             void setCursorName(const OUString &_par0);
      99             :             void setEscapeProcessing( const bool _bEscapeProc );
     100             :             template < typename T, SQLINTEGER BufferLength > SQLRETURN setStmtOption (SQLINTEGER fOption, T value) const;
     101             : 
     102             :             void setResultSetConcurrency(sal_Int32 _par0)   ;
     103             :             void setResultSetType(sal_Int32 _par0)          ;
     104             :             void setUsingBookmarks(bool _bUseBookmark)  ;
     105             : 
     106             :             void reset() throw (css::sdbc::SQLException, css::uno::RuntimeException);
     107             :             void clearMyResultSet() throw (css::sdbc::SQLException, css::uno::RuntimeException);
     108             :             void setWarning (const ::com::sun::star::sdbc::SQLWarning &ex)
     109             :                 throw (css::sdbc::SQLException, css::uno::RuntimeException);
     110             :             bool lockIfNecessary (const OUString& sql) throw (css::sdbc::SQLException, css::uno::RuntimeException);
     111             :             sal_Int32 getColumnCount() throw (css::sdbc::SQLException, css::uno::RuntimeException);
     112             : 
     113             : 
     114             :             // getResultSet
     115             :             // getResultSet returns the current result as a ResultSet.  It
     116             :             // returns NULL if the current result is not a ResultSet.
     117             : 
     118             :             css::uno::Reference<css::sdbc::XResultSet> getResultSet(bool checkCount)
     119             :                 throw (css::sdbc::SQLException, css::uno::RuntimeException);
     120             :             /**
     121             :                 creates the driver specific resultset (factory)
     122             :             */
     123             :             virtual OResultSet* createResulSet();
     124             : 
     125             :             SQLLEN getRowCount() throw (css::sdbc::SQLException, css::uno::RuntimeException);
     126             : 
     127             : 
     128             :             void disposeResultSet();
     129             : 
     130             :             // OPropertyArrayUsageHelper
     131             :             virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
     132             :             // OPropertySetHelper
     133             :             virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() SAL_OVERRIDE;
     134             :             virtual sal_Bool SAL_CALL convertFastPropertyValue(
     135             :                                 ::com::sun::star::uno::Any & rConvertedValue,
     136             :                                 ::com::sun::star::uno::Any & rOldValue,
     137             :                                 sal_Int32 nHandle,
     138             :                                 const ::com::sun::star::uno::Any& rValue )
     139             :                             throw (::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
     140             :             virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
     141             :                                     sal_Int32 nHandle,
     142             :                                     const ::com::sun::star::uno::Any& rValue
     143             :                                                      )
     144             :                                  throw (::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
     145             :             virtual void SAL_CALL getFastPropertyValue(
     146             :                                     ::com::sun::star::uno::Any& rValue,
     147             :                                     sal_Int32 nHandle
     148             :                                          ) const SAL_OVERRIDE;
     149             :             virtual ~OStatement_Base();
     150             : 
     151             :         public:
     152             :             OStatement_Base(OConnection* _pConnection );
     153             :             using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
     154             : 
     155           0 :             inline oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex)  const
     156             :             {
     157           0 :                 return m_pConnection->getOdbcFunction(_nIndex);
     158             :             }
     159             :             // OComponentHelper
     160             :             virtual void SAL_CALL disposing() SAL_OVERRIDE;
     161             :             // XInterface
     162             :             virtual void SAL_CALL release() throw() SAL_OVERRIDE;
     163             :             virtual void SAL_CALL acquire() throw() SAL_OVERRIDE;
     164             :             // XInterface
     165             :             virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     166             :             //XTypeProvider
     167             :             virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     168             : 
     169             :             // XPropertySet
     170             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     171             :             // XStatement
     172             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
     173             :             virtual sal_Int32 SAL_CALL executeUpdate( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
     174             :             virtual sal_Bool SAL_CALL execute( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
     175             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
     176             :             // XWarningsSupplier
     177             :             virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     178             :             virtual void SAL_CALL clearWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     179             :             // XCancellable
     180             :             virtual void SAL_CALL cancel(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     181             :             // XCloseable
     182             :             virtual void SAL_CALL close(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     183             :             // XMultipleResults
     184             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     185             :             virtual sal_Int32 SAL_CALL getUpdateCount(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     186             :             virtual sal_Bool SAL_CALL getMoreResults(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     187             :             //XGeneratedResultSet
     188             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getGeneratedValues(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     189             : 
     190             :             // other methods
     191           0 :             SQLHANDLE getConnectionHandle() { return m_pConnection->getConnection(); }
     192           0 :             OConnection* getOwnConnection() const { return m_pConnection;}
     193             :             /** getCursorProperties return the properties for a specific cursor type
     194             :                 @param _nCursorType     the CursorType
     195             :                 @param bFirst           when true the first property set is returned
     196             : 
     197             :                 @return the cursor properties
     198             :             */
     199             :             SQLUINTEGER getCursorProperties(SQLINTEGER _nCursorType, bool bFirst);
     200             : 
     201             :         protected:
     202             :             using OPropertySetHelper::getFastPropertyValue;
     203             :         };
     204             : 
     205           0 :         class OOO_DLLPUBLIC_ODBCBASE OStatement_BASE2 :
     206             :                                  public OStatement_Base
     207             :                                 ,public ::connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>
     208             : 
     209             :         {
     210             :             friend class OSubComponent<OStatement_BASE2, OStatement_BASE>;
     211             :         public:
     212           0 :             OStatement_BASE2(OConnection* _pConnection ) :  OStatement_Base(_pConnection ),
     213           0 :                                     ::connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>(static_cast<cppu::OWeakObject*>(_pConnection), this){}
     214             :             // OComponentHelper
     215             :             virtual void SAL_CALL disposing() SAL_OVERRIDE;
     216             :             // XInterface
     217             :             virtual void SAL_CALL release() throw() SAL_OVERRIDE;
     218             :         };
     219             : 
     220             :         class OOO_DLLPUBLIC_ODBCBASE OStatement :
     221             :                             public OStatement_BASE2,
     222             :                             public ::com::sun::star::sdbc::XBatchExecution,
     223             :                             public ::com::sun::star::lang::XServiceInfo
     224             :         {
     225             :         protected:
     226           0 :             virtual ~OStatement(){}
     227             :         public:
     228             :             // A ctor that is needed for returning the object
     229           0 :             OStatement( OConnection* _pConnection) : OStatement_BASE2( _pConnection){}
     230             :             DECLARE_SERVICE_INFO();
     231             : 
     232             :             virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     233             :             virtual void SAL_CALL acquire() throw() SAL_OVERRIDE;
     234             :             virtual void SAL_CALL release() throw() SAL_OVERRIDE;
     235             :             // XBatchExecution
     236             :             virtual void SAL_CALL addBatch( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     237             :             virtual void SAL_CALL clearBatch(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     238             :             virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     239             :         };
     240             :     }
     241             : }
     242             : #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_OSTATEMENT_HXX
     243             : 
     244             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11