LCOV - code coverage report
Current view: top level - connectivity/source/inc/file - FStatement.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 7 7 100.0 %
Date: 2014-11-03 Functions: 6 8 75.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_FILE_FSTATEMENT_HXX
      21             : #define INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FSTATEMENT_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/util/XCancellable.hpp>
      30             : #include <comphelper/proparrhlp.hxx>
      31             : #include <cppuhelper/compbase3.hxx>
      32             : #include <cppuhelper/implbase2.hxx>
      33             : #include <comphelper/uno3.hxx>
      34             : #include <connectivity/CommonTools.hxx>
      35             : #include "file/FConnection.hxx"
      36             : #include "file/filedllapi.hxx"
      37             : #include <list>
      38             : #include <com/sun/star/lang/XServiceInfo.hpp>
      39             : #include <comphelper/propertycontainer.hxx>
      40             : #include "file/fanalyzer.hxx"
      41             : #include <comphelper/broadcasthelper.hxx>
      42             : #include "TSortIndex.hxx"
      43             : 
      44             : namespace connectivity
      45             : {
      46             :     namespace file
      47             :     {
      48             :         class OResultSet;
      49             :         class OFileTable;
      50             :         typedef ::cppu::WeakComponentImplHelper3<   ::com::sun::star::sdbc::XWarningsSupplier,
      51             :                                                     ::com::sun::star::util::XCancellable,
      52             :                                                     ::com::sun::star::sdbc::XCloseable> OStatement_BASE;
      53             : 
      54             : 
      55             :         //************ Class: java.sql.Statement
      56             : 
      57             :         class OOO_DLLPUBLIC_FILE OStatement_Base :
      58             :                                         public  comphelper::OBaseMutex,
      59             :                                         public  OStatement_BASE,
      60             :                                         public  ::comphelper::OPropertyContainer,
      61             :                                         public  ::comphelper::OPropertyArrayUsageHelper<OStatement_Base>
      62             : 
      63             :         {
      64             :         protected:
      65             :             ::std::vector<sal_Int32>                    m_aColMapping; // pos 0 is unused so we don't have to decrement 1 every time
      66             :             ::std::vector<sal_Int32>                    m_aParameterIndexes; // maps the parameter index to column index
      67             :             ::std::vector<sal_Int32>                    m_aOrderbyColumnNumber;
      68             :             ::std::vector<TAscendingOrder>              m_aOrderbyAscending;
      69             : 
      70             :             ::com::sun::star::sdbc::SQLWarning                                           m_aLastWarning;
      71             :             ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet>    m_xResultSet;   // The last ResultSet created
      72             :             ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xDBMetaData;
      73             :             ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>  m_xColNames; // table columns                                                          //  for this Statement
      74             : 
      75             : 
      76             :             connectivity::OSQLParser                    m_aParser;
      77             :             connectivity::OSQLParseTreeIterator         m_aSQLIterator;
      78             : 
      79             :             OConnection*                                m_pConnection;// The owning Connection object
      80             :             connectivity::OSQLParseNode*                m_pParseTree;
      81             :             OSQLAnalyzer*                               m_pSQLAnalyzer; //the sql analyzer used by the resultset
      82             : 
      83             :             ::std::vector<sal_Int32>*                   m_pEvaluationKeySet;
      84             : 
      85             :             OFileTable*                                 m_pTable;       // the current table
      86             :             OValueRefRow                                m_aSelectRow;
      87             :             OValueRefRow                                m_aRow;
      88             :             OValueRefRow                                m_aEvaluateRow; // contains all values of a row
      89             :             ORefAssignValues                            m_aAssignValues; // needed for insert,update and parameters
      90             :                                                                     // to compare with the restrictions
      91             : 
      92             :             OUString                             m_aCursorName;
      93             :             sal_Int32                                   m_nMaxFieldSize;
      94             :             sal_Int32                                   m_nMaxRows;
      95             :             sal_Int32                                   m_nQueryTimeOut;
      96             :             sal_Int32                                   m_nFetchSize;
      97             :             sal_Int32                                   m_nResultSetType;
      98             :             sal_Int32                                   m_nFetchDirection;
      99             :             sal_Int32                                   m_nResultSetConcurrency;
     100             :             bool                                    m_bEscapeProcessing;
     101             : 
     102             :             ::cppu::OBroadcastHelper&                   rBHelper;
     103             : 
     104             :         protected:
     105             :             // initialize the column index map (mapping select columns to table columns)
     106             :             void createColumnMapping();
     107             :             // searches the statement for sort criteria
     108             :             void anylizeSQL();
     109             :             void setOrderbyColumn( connectivity::OSQLParseNode* pColumnRef,
     110             :                                      connectivity::OSQLParseNode* pAscendingDescending);
     111             : 
     112             :             virtual void initializeResultSet(OResultSet* _pResult);
     113             :             // create the analyzer
     114             :             virtual OSQLAnalyzer* createAnalyzer();
     115             : 
     116             :             void closeResultSet() throw (css::sdbc::SQLException, css::uno::RuntimeException, std::exception);
     117             :             sal_Int32 getPrecision ( sal_Int32 sqlType);
     118             : 
     119             :             void disposeResultSet();
     120             :             void GetAssignValues();
     121             :             void SetAssignValue(const OUString& aColumnName,
     122             :                                    const OUString& aValue,
     123             :                                    bool bSetNull = false,
     124             :                                    sal_uInt32 nParameter=SQL_NO_PARAMETER);
     125             :             void ParseAssignValues( const ::std::vector< OUString>& aColumnNameList,
     126             :                                     connectivity::OSQLParseNode* pRow_Value_Constructor_Elem, sal_Int32 nIndex);
     127             : 
     128             :             virtual void parseParamterElem(const OUString& _sColumnName,OSQLParseNode* pRow_Value_Constructor_Elem);
     129             :             // factory method for resultset's
     130             :             virtual OResultSet* createResultSet() = 0;
     131             :             // OPropertyArrayUsageHelper
     132             :             virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
     133             :             // OPropertySetHelper
     134             :             virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() SAL_OVERRIDE;
     135             :             virtual ~OStatement_Base();
     136             :         public:
     137          46 :             connectivity::OSQLParseNode* getParseTree() const { return m_pParseTree;}
     138             : 
     139             :             OStatement_Base(OConnection* _pConnection );
     140             : 
     141         140 :             OConnection* getOwnConnection() const { return m_pConnection;}
     142             : 
     143             :             using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
     144             : 
     145             :             virtual void construct(const OUString& sql)  throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     146             : 
     147             :             // OComponentHelper
     148             :             virtual void SAL_CALL disposing(void) SAL_OVERRIDE;
     149             :             // XInterface
     150             :             //      virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException) = 0;
     151             :             virtual void SAL_CALL acquire() throw() SAL_OVERRIDE;
     152             :             // XInterface
     153             :             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;
     154             :             //XTypeProvider
     155             :             virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     156             : 
     157             :             // XPropertySet
     158             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     159             :             // XWarningsSupplier
     160             :             virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     161             :             virtual void SAL_CALL clearWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     162             :             // XCancellable
     163             :             virtual void SAL_CALL cancel(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     164             :             // XCloseable
     165             :             virtual void SAL_CALL close(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     166             :         };
     167             : 
     168         132 :         class OOO_DLLPUBLIC_FILE OStatement_BASE2 :
     169             :                                     public OStatement_Base,
     170             :                                     public connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>
     171             : 
     172             :         {
     173             :             friend class connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>;
     174             :         public:
     175         132 :             OStatement_BASE2(OConnection* _pConnection ) :  OStatement_Base(_pConnection ),
     176         132 :                                     connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this){}
     177             :             // OComponentHelper
     178             :             virtual void SAL_CALL disposing(void) SAL_OVERRIDE;
     179             :             // XInterface
     180             :             virtual void SAL_CALL release() throw() SAL_OVERRIDE;
     181             :         };
     182             : 
     183             :         typedef ::cppu::ImplHelper2< ::com::sun::star::sdbc::XStatement,::com::sun::star::lang::XServiceInfo > OStatement_XStatement;
     184          22 :         class OOO_DLLPUBLIC_FILE OStatement :
     185             :                             public OStatement_BASE2,
     186             :                             public OStatement_XStatement
     187             :         {
     188             :         protected:
     189             :             // factory method for resultset's
     190             :             virtual OResultSet* createResultSet() SAL_OVERRIDE;
     191             :         public:
     192             :             // a Constructor, that is needed for when Returning the Object is needed:
     193          22 :             OStatement( OConnection* _pConnection) : OStatement_BASE2( _pConnection){}
     194             :             DECLARE_SERVICE_INFO();
     195             : 
     196             :             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;
     197             :             virtual void SAL_CALL acquire() throw() SAL_OVERRIDE;
     198             :             virtual void SAL_CALL release() throw() SAL_OVERRIDE;
     199             : 
     200             :             // XStatement
     201             :             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 ;
     202             :             virtual sal_Int32 SAL_CALL executeUpdate( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
     203             :             virtual sal_Bool SAL_CALL execute( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
     204             :             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 ;
     205             :         };
     206             :     }
     207             : }
     208             : #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FSTATEMENT_HXX
     209             : 
     210             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10