LCOV - code coverage report
Current view: top level - connectivity/source/inc/file - FStatement.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 7 7 100.0 %
Date: 2012-08-25 Functions: 6 8 75.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 4 8 50.0 %

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

Generated by: LCOV version 1.10