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 10*caf5cd79SAndrew Rist * 11*caf5cd79SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*caf5cd79SAndrew Rist * 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. 19*caf5cd79SAndrew Rist * 20*caf5cd79SAndrew Rist *************************************************************/ 21*caf5cd79SAndrew Rist 22*caf5cd79SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _CONNECTIVITY_MACAB_STATEMENT_HXX_ 25cdf0e10cSrcweir #define _CONNECTIVITY_MACAB_STATEMENT_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "MacabConnection.hxx" 28cdf0e10cSrcweir #include "MacabHeader.hxx" 29cdf0e10cSrcweir #include <list> 30cdf0e10cSrcweir #include "connectivity/sqliterator.hxx" 31cdf0e10cSrcweir #ifndef _CONNECTIVITY_PARSE_SQLPARSE_HXX_ 32cdf0e10cSrcweir #include "connectivity/sqlparse.hxx" 33cdf0e10cSrcweir #endif 34cdf0e10cSrcweir #include <com/sun/star/sdbc/XStatement.hpp> 35cdf0e10cSrcweir #include <com/sun/star/util/XCancellable.hpp> 36cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx> 37cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 38cdf0e10cSrcweir #include <comphelper/proparrhlp.hxx> 39cdf0e10cSrcweir 40cdf0e10cSrcweir namespace connectivity 41cdf0e10cSrcweir { 42cdf0e10cSrcweir namespace macab 43cdf0e10cSrcweir { 44cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::sdbc::XStatement, 45cdf0e10cSrcweir ::com::sun::star::sdbc::XWarningsSupplier, 46cdf0e10cSrcweir ::com::sun::star::util::XCancellable, 47cdf0e10cSrcweir ::com::sun::star::sdbc::XCloseable> MacabCommonStatement_BASE; 48cdf0e10cSrcweir 49cdf0e10cSrcweir //************************************************************** 50cdf0e10cSrcweir // Class MacabCommonStatement 51cdf0e10cSrcweir // is a base class for the normal statement and for the prepared statement 52cdf0e10cSrcweir //************************************************************** 53cdf0e10cSrcweir class MacabCommonStatement : public comphelper::OBaseMutex, 54cdf0e10cSrcweir public MacabCommonStatement_BASE, 55cdf0e10cSrcweir public ::cppu::OPropertySetHelper, 56cdf0e10cSrcweir public comphelper::OPropertyArrayUsageHelper<MacabCommonStatement> 57cdf0e10cSrcweir 58cdf0e10cSrcweir { 59cdf0e10cSrcweir ::com::sun::star::sdbc::SQLWarning m_aLastWarning; 60cdf0e10cSrcweir 61cdf0e10cSrcweir protected: 62cdf0e10cSrcweir ::std::list< ::rtl::OUString> m_aBatchList; 63cdf0e10cSrcweir connectivity::OSQLParser m_aParser; 64cdf0e10cSrcweir connectivity::OSQLParseTreeIterator m_aSQLIterator; 65cdf0e10cSrcweir connectivity::OSQLParseNode* m_pParseTree; 66cdf0e10cSrcweir MacabConnection* m_pConnection; // The owning Connection object 67cdf0e10cSrcweir MacabHeader* m_pHeader; // The header of the address book on which to run queries (provided by m_pConnection) 68cdf0e10cSrcweir ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created 69cdf0e10cSrcweir 70cdf0e10cSrcweir 71cdf0e10cSrcweir protected: 72cdf0e10cSrcweir class MacabCondition *analyseWhereClause( 73cdf0e10cSrcweir const OSQLParseNode *pParseNode) const throw(::com::sun::star::sdbc::SQLException); 74cdf0e10cSrcweir class MacabOrder *analyseOrderByClause( 75cdf0e10cSrcweir const OSQLParseNode *pParseNode) const throw(::com::sun::star::sdbc::SQLException); 76cdf0e10cSrcweir ::rtl::OUString getTableName( ) const; 77cdf0e10cSrcweir void setMacabFields(class MacabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException); 78cdf0e10cSrcweir void selectRecords(MacabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException); 79cdf0e10cSrcweir void sortRecords(MacabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException); 80cdf0e10cSrcweir 81cdf0e10cSrcweir // OPropertyArrayUsageHelper 82cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; 83cdf0e10cSrcweir 84cdf0e10cSrcweir // OPropertySetHelper 85cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); 86cdf0e10cSrcweir virtual sal_Bool SAL_CALL convertFastPropertyValue( 87cdf0e10cSrcweir ::com::sun::star::uno::Any & rConvertedValue, 88cdf0e10cSrcweir ::com::sun::star::uno::Any & rOldValue, 89cdf0e10cSrcweir sal_Int32 nHandle, 90cdf0e10cSrcweir const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::lang::IllegalArgumentException); 91cdf0e10cSrcweir virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 92cdf0e10cSrcweir sal_Int32 nHandle, 93cdf0e10cSrcweir const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception); 94cdf0e10cSrcweir virtual void SAL_CALL getFastPropertyValue( 95cdf0e10cSrcweir ::com::sun::star::uno::Any& rValue, 96cdf0e10cSrcweir sal_Int32 nHandle) const; 97cdf0e10cSrcweir 98cdf0e10cSrcweir virtual void resetParameters() const throw(::com::sun::star::sdbc::SQLException); 99cdf0e10cSrcweir virtual void getNextParameter(::rtl::OUString &rParameter) const throw(::com::sun::star::sdbc::SQLException); 100cdf0e10cSrcweir virtual ~MacabCommonStatement(); 101cdf0e10cSrcweir 102cdf0e10cSrcweir public: 103cdf0e10cSrcweir ::cppu::OBroadcastHelper& rBHelper; 104cdf0e10cSrcweir 105cdf0e10cSrcweir MacabCommonStatement(MacabConnection *_pConnection); 106cdf0e10cSrcweir using MacabCommonStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; 107cdf0e10cSrcweir 108cdf0e10cSrcweir // OComponentHelper 109cdf0e10cSrcweir virtual void SAL_CALL disposing(); 110cdf0e10cSrcweir 111cdf0e10cSrcweir // XInterface 112cdf0e10cSrcweir virtual void SAL_CALL release() throw(); 113cdf0e10cSrcweir virtual void SAL_CALL acquire() throw(); 114cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( 115cdf0e10cSrcweir const ::com::sun::star::uno::Type & rType 116cdf0e10cSrcweir ) throw(::com::sun::star::uno::RuntimeException); 117cdf0e10cSrcweir 118cdf0e10cSrcweir // XTypeProvider 119cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( 120cdf0e10cSrcweir ) throw(::com::sun::star::uno::RuntimeException); 121cdf0e10cSrcweir 122cdf0e10cSrcweir // XPropertySet 123cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( 124cdf0e10cSrcweir ) throw(::com::sun::star::uno::RuntimeException); 125cdf0e10cSrcweir 126cdf0e10cSrcweir // XStatement 127cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( 128cdf0e10cSrcweir const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 129cdf0e10cSrcweir virtual sal_Int32 SAL_CALL executeUpdate( 130cdf0e10cSrcweir const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 131cdf0e10cSrcweir virtual sal_Bool SAL_CALL execute( 132cdf0e10cSrcweir const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 133cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( 134cdf0e10cSrcweir ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 135cdf0e10cSrcweir 136cdf0e10cSrcweir // XWarningsSupplier 137cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( 138cdf0e10cSrcweir ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 139cdf0e10cSrcweir virtual void SAL_CALL clearWarnings( 140cdf0e10cSrcweir ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 141cdf0e10cSrcweir 142cdf0e10cSrcweir // XCancellable 143cdf0e10cSrcweir virtual void SAL_CALL cancel( 144cdf0e10cSrcweir ) throw(::com::sun::star::uno::RuntimeException); 145cdf0e10cSrcweir 146cdf0e10cSrcweir // XCloseable 147cdf0e10cSrcweir virtual void SAL_CALL close( 148cdf0e10cSrcweir ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 149cdf0e10cSrcweir 150cdf0e10cSrcweir // other methods getOwnConnection() const151cdf0e10cSrcweir inline MacabConnection* getOwnConnection() const { return m_pConnection; } 152cdf0e10cSrcweir }; 153cdf0e10cSrcweir 154cdf0e10cSrcweir //************************************************************** 155cdf0e10cSrcweir // Class MacabStatement 156cdf0e10cSrcweir //************************************************************** 157cdf0e10cSrcweir typedef ::cppu::ImplInheritanceHelper1< 158cdf0e10cSrcweir MacabCommonStatement, ::com::sun::star::lang::XServiceInfo > MacabStatement_BASE; 159cdf0e10cSrcweir 160cdf0e10cSrcweir class MacabStatement : public MacabStatement_BASE 161cdf0e10cSrcweir { 162cdf0e10cSrcweir protected: ~MacabStatement()163cdf0e10cSrcweir virtual ~MacabStatement() { } 164cdf0e10cSrcweir 165cdf0e10cSrcweir public: 166cdf0e10cSrcweir MacabStatement(MacabConnection* _pConnection); 167cdf0e10cSrcweir DECLARE_SERVICE_INFO(); 168cdf0e10cSrcweir }; 169cdf0e10cSrcweir } 170cdf0e10cSrcweir } 171cdf0e10cSrcweir 172cdf0e10cSrcweir #endif // _CONNECTIVITY_MACAB_STATEMENT_HXX_ 173