1*caf5cd79SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*caf5cd79SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*caf5cd79SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*caf5cd79SAndrew Rist * distributed with this work for additional information 6*caf5cd79SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*caf5cd79SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*caf5cd79SAndrew Rist * "License"); you may not use this file except in compliance 9*caf5cd79SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*caf5cd79SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*caf5cd79SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*caf5cd79SAndrew Rist * software distributed under the License is distributed on an 15*caf5cd79SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*caf5cd79SAndrew Rist * KIND, either express or implied. See the License for the 17*caf5cd79SAndrew Rist * specific language governing permissions and limitations 18*caf5cd79SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*caf5cd79SAndrew Rist *************************************************************/ 21*caf5cd79SAndrew Rist 22*caf5cd79SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _CONNECTIVITY_KAB_STATEMENT_HXX_ 25cdf0e10cSrcweir #define _CONNECTIVITY_KAB_STATEMENT_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "KConnection.hxx" 28cdf0e10cSrcweir #include <list> 29cdf0e10cSrcweir #include "connectivity/sqliterator.hxx" 30cdf0e10cSrcweir #ifndef _CONNECTIVITY_PARSE_SQLPARSE_HXX_ 31cdf0e10cSrcweir #include "connectivity/sqlparse.hxx" 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #include <com/sun/star/sdbc/XStatement.hpp> 34cdf0e10cSrcweir #include <com/sun/star/util/XCancellable.hpp> 35cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx> 36cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 37cdf0e10cSrcweir #include <comphelper/proparrhlp.hxx> 38cdf0e10cSrcweir 39cdf0e10cSrcweir namespace connectivity 40cdf0e10cSrcweir { 41cdf0e10cSrcweir namespace kab 42cdf0e10cSrcweir { 43cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::sdbc::XStatement, 44cdf0e10cSrcweir ::com::sun::star::sdbc::XWarningsSupplier, 45cdf0e10cSrcweir ::com::sun::star::util::XCancellable, 46cdf0e10cSrcweir ::com::sun::star::sdbc::XCloseable> KabCommonStatement_BASE; 47cdf0e10cSrcweir 48cdf0e10cSrcweir //************************************************************** 49cdf0e10cSrcweir // Class KabCommonStatement 50cdf0e10cSrcweir // is a base class for the normal statement and for the prepared statement 51cdf0e10cSrcweir //************************************************************** 52cdf0e10cSrcweir class KabCommonStatement : public comphelper::OBaseMutex, 53cdf0e10cSrcweir public KabCommonStatement_BASE, 54cdf0e10cSrcweir public ::cppu::OPropertySetHelper, 55cdf0e10cSrcweir public comphelper::OPropertyArrayUsageHelper<KabCommonStatement> 56cdf0e10cSrcweir 57cdf0e10cSrcweir { 58cdf0e10cSrcweir ::com::sun::star::sdbc::SQLWarning m_aLastWarning; 59cdf0e10cSrcweir 60cdf0e10cSrcweir protected: 61cdf0e10cSrcweir ::std::list< ::rtl::OUString> m_aBatchList; 62cdf0e10cSrcweir connectivity::OSQLParser m_aParser; 63cdf0e10cSrcweir connectivity::OSQLParseTreeIterator m_aSQLIterator; 64cdf0e10cSrcweir connectivity::OSQLParseNode* m_pParseTree; 65cdf0e10cSrcweir KabConnection* m_pConnection; // The owning Connection object 66cdf0e10cSrcweir 67cdf0e10cSrcweir protected: 68cdf0e10cSrcweir class KabCondition *analyseWhereClause( 69cdf0e10cSrcweir const OSQLParseNode *pParseNode) const throw(::com::sun::star::sdbc::SQLException); 70cdf0e10cSrcweir class KabOrder *analyseOrderByClause( 71cdf0e10cSrcweir const OSQLParseNode *pParseNode) const throw(::com::sun::star::sdbc::SQLException); 72cdf0e10cSrcweir sal_Bool isTableKnown(class KabResultSet *pResult) const; 73cdf0e10cSrcweir void setKabFields(class KabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException); 74cdf0e10cSrcweir void selectAddressees(KabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException); 75cdf0e10cSrcweir void sortAddressees(KabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException); 76cdf0e10cSrcweir 77cdf0e10cSrcweir // OPropertyArrayUsageHelper 78cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; 79cdf0e10cSrcweir 80cdf0e10cSrcweir // OPropertySetHelper 81cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); 82cdf0e10cSrcweir virtual sal_Bool SAL_CALL convertFastPropertyValue( 83cdf0e10cSrcweir ::com::sun::star::uno::Any & rConvertedValue, 84cdf0e10cSrcweir ::com::sun::star::uno::Any & rOldValue, 85cdf0e10cSrcweir sal_Int32 nHandle, 86cdf0e10cSrcweir const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::lang::IllegalArgumentException); 87cdf0e10cSrcweir virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 88cdf0e10cSrcweir sal_Int32 nHandle, 89cdf0e10cSrcweir const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception); 90cdf0e10cSrcweir virtual void SAL_CALL getFastPropertyValue( 91cdf0e10cSrcweir ::com::sun::star::uno::Any& rValue, 92cdf0e10cSrcweir sal_Int32 nHandle) const; 93cdf0e10cSrcweir 94cdf0e10cSrcweir virtual void resetParameters() const throw(::com::sun::star::sdbc::SQLException); 95cdf0e10cSrcweir virtual void getNextParameter(::rtl::OUString &rParameter) const throw(::com::sun::star::sdbc::SQLException); 96cdf0e10cSrcweir virtual ~KabCommonStatement(); 97cdf0e10cSrcweir 98cdf0e10cSrcweir public: 99cdf0e10cSrcweir ::cppu::OBroadcastHelper& rBHelper; 100cdf0e10cSrcweir 101cdf0e10cSrcweir KabCommonStatement(KabConnection *_pConnection); 102cdf0e10cSrcweir using KabCommonStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; 103cdf0e10cSrcweir 104cdf0e10cSrcweir // OComponentHelper 105cdf0e10cSrcweir virtual void SAL_CALL disposing(); 106cdf0e10cSrcweir 107cdf0e10cSrcweir // XInterface 108cdf0e10cSrcweir virtual void SAL_CALL release() throw(); 109cdf0e10cSrcweir virtual void SAL_CALL acquire() throw(); 110cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( 111cdf0e10cSrcweir const ::com::sun::star::uno::Type & rType 112cdf0e10cSrcweir ) throw(::com::sun::star::uno::RuntimeException); 113cdf0e10cSrcweir 114cdf0e10cSrcweir // XTypeProvider 115cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( 116cdf0e10cSrcweir ) throw(::com::sun::star::uno::RuntimeException); 117cdf0e10cSrcweir 118cdf0e10cSrcweir // XPropertySet 119cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( 120cdf0e10cSrcweir ) throw(::com::sun::star::uno::RuntimeException); 121cdf0e10cSrcweir 122cdf0e10cSrcweir // XStatement 123cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( 124cdf0e10cSrcweir const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 125cdf0e10cSrcweir virtual sal_Int32 SAL_CALL executeUpdate( 126cdf0e10cSrcweir const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 127cdf0e10cSrcweir virtual sal_Bool SAL_CALL execute( 128cdf0e10cSrcweir const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 129cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( 130cdf0e10cSrcweir ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 131cdf0e10cSrcweir 132cdf0e10cSrcweir // XWarningsSupplier 133cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( 134cdf0e10cSrcweir ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 135cdf0e10cSrcweir virtual void SAL_CALL clearWarnings( 136cdf0e10cSrcweir ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 137cdf0e10cSrcweir 138cdf0e10cSrcweir // XCancellable 139cdf0e10cSrcweir virtual void SAL_CALL cancel( 140cdf0e10cSrcweir ) throw(::com::sun::star::uno::RuntimeException); 141cdf0e10cSrcweir 142cdf0e10cSrcweir // XCloseable 143cdf0e10cSrcweir virtual void SAL_CALL close( 144cdf0e10cSrcweir ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 145cdf0e10cSrcweir 146cdf0e10cSrcweir // other methods getOwnConnection() const147cdf0e10cSrcweir inline KabConnection* getOwnConnection() const { return m_pConnection; } 148cdf0e10cSrcweir }; 149cdf0e10cSrcweir 150cdf0e10cSrcweir //************************************************************** 151cdf0e10cSrcweir // Class KabStatement 152cdf0e10cSrcweir //************************************************************** 153cdf0e10cSrcweir typedef ::cppu::ImplInheritanceHelper1< 154cdf0e10cSrcweir KabCommonStatement, ::com::sun::star::lang::XServiceInfo > KabStatement_BASE; 155cdf0e10cSrcweir 156cdf0e10cSrcweir class KabStatement : public KabStatement_BASE 157cdf0e10cSrcweir { 158cdf0e10cSrcweir protected: ~KabStatement()159cdf0e10cSrcweir virtual ~KabStatement() { } 160cdf0e10cSrcweir 161cdf0e10cSrcweir public: 162cdf0e10cSrcweir KabStatement(KabConnection* _pConnection); 163cdf0e10cSrcweir DECLARE_SERVICE_INFO(); 164cdf0e10cSrcweir }; 165cdf0e10cSrcweir } 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir #endif // _CONNECTIVITY_KAB_STATEMENT_HXX_ 169