xref: /AOO41X/main/connectivity/source/drivers/kab/KStatement.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _CONNECTIVITY_KAB_STATEMENT_HXX_
29 #define _CONNECTIVITY_KAB_STATEMENT_HXX_
30 
31 #include "KConnection.hxx"
32 #include <list>
33 #include "connectivity/sqliterator.hxx"
34 #ifndef _CONNECTIVITY_PARSE_SQLPARSE_HXX_
35 #include "connectivity/sqlparse.hxx"
36 #endif
37 #include <com/sun/star/sdbc/XStatement.hpp>
38 #include <com/sun/star/util/XCancellable.hpp>
39 #include <cppuhelper/compbase4.hxx>
40 #include <cppuhelper/implbase1.hxx>
41 #include <comphelper/proparrhlp.hxx>
42 
43 namespace connectivity
44 {
45 	namespace kab
46 	{
47 		typedef ::cppu::WeakComponentImplHelper4<	::com::sun::star::sdbc::XStatement,
48                                                     ::com::sun::star::sdbc::XWarningsSupplier,
49                                                     ::com::sun::star::util::XCancellable,
50                                                     ::com::sun::star::sdbc::XCloseable> KabCommonStatement_BASE;
51 
52 		//**************************************************************
53 		// Class KabCommonStatement
54 		// is a base class for the normal statement and for the prepared statement
55 		//**************************************************************
56 		class KabCommonStatement :	public comphelper::OBaseMutex,
57 						public	KabCommonStatement_BASE,
58 						public	::cppu::OPropertySetHelper,
59 						public	comphelper::OPropertyArrayUsageHelper<KabCommonStatement>
60 
61 		{
62 			::com::sun::star::sdbc::SQLWarning	m_aLastWarning;
63 
64 		protected:
65 			::std::list< ::rtl::OUString>		m_aBatchList;
66 			connectivity::OSQLParser			m_aParser;
67 			connectivity::OSQLParseTreeIterator	m_aSQLIterator;
68 			connectivity::OSQLParseNode*		m_pParseTree;
69 			KabConnection*						m_pConnection;	// The owning Connection object
70 
71 		protected:
72 			class KabCondition *analyseWhereClause(
73 				const OSQLParseNode *pParseNode) const throw(::com::sun::star::sdbc::SQLException);
74 			class KabOrder *analyseOrderByClause(
75 				const OSQLParseNode *pParseNode) const throw(::com::sun::star::sdbc::SQLException);
76 			sal_Bool isTableKnown(class KabResultSet *pResult) const;
77 			void setKabFields(class KabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException);
78 			void selectAddressees(KabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException);
79 			void sortAddressees(KabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException);
80 
81 			// OPropertyArrayUsageHelper
82 			virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
83 
84 			// OPropertySetHelper
85 			virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
86 			virtual sal_Bool SAL_CALL convertFastPropertyValue(
87 					::com::sun::star::uno::Any & rConvertedValue,
88 					::com::sun::star::uno::Any & rOldValue,
89 					sal_Int32 nHandle,
90 					const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::lang::IllegalArgumentException);
91 			virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
92 					sal_Int32 nHandle,
93 					const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
94 			virtual void SAL_CALL getFastPropertyValue(
95 					::com::sun::star::uno::Any& rValue,
96 					sal_Int32 nHandle) const;
97 
98 			virtual void resetParameters() const throw(::com::sun::star::sdbc::SQLException);
99 			virtual void getNextParameter(::rtl::OUString &rParameter) const throw(::com::sun::star::sdbc::SQLException);
100 			virtual ~KabCommonStatement();
101 
102 		public:
103 			::cppu::OBroadcastHelper& rBHelper;
104 
105 			KabCommonStatement(KabConnection *_pConnection);
106 			using KabCommonStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
107 
108 			// OComponentHelper
109 			virtual void SAL_CALL disposing();
110 
111 			// XInterface
112 			virtual void SAL_CALL release() throw();
113 			virtual void SAL_CALL acquire() throw();
114 			virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
115 					const ::com::sun::star::uno::Type & rType
116 					) throw(::com::sun::star::uno::RuntimeException);
117 
118 			// XTypeProvider
119 			virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(
120 					) throw(::com::sun::star::uno::RuntimeException);
121 
122 			// XPropertySet
123 			virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(
124 					) throw(::com::sun::star::uno::RuntimeException);
125 
126 			// XStatement
127 			virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery(
128 					const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
129 			virtual sal_Int32 SAL_CALL executeUpdate(
130 					 const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
131 			virtual sal_Bool SAL_CALL execute(
132 					const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
133 			virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection(
134 					) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
135 
136 			// XWarningsSupplier
137 			virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(
138 					) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
139 			virtual void SAL_CALL clearWarnings(
140 					) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
141 
142 			// XCancellable
143 			virtual void SAL_CALL cancel(
144 					) throw(::com::sun::star::uno::RuntimeException);
145 
146 			// XCloseable
147 			virtual void SAL_CALL close(
148 					) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
149 
150 			// other methods
151 			inline KabConnection* getOwnConnection() const { return m_pConnection; }
152 		};
153 
154 		//**************************************************************
155 		// Class KabStatement
156 		//**************************************************************
157 		typedef ::cppu::ImplInheritanceHelper1<
158 				KabCommonStatement, ::com::sun::star::lang::XServiceInfo > KabStatement_BASE;
159 
160 		class KabStatement : public KabStatement_BASE
161 		{
162 		protected:
163 			virtual ~KabStatement() { }
164 
165 		public:
166 			KabStatement(KabConnection* _pConnection);
167 			DECLARE_SERVICE_INFO();
168 		};
169 	}
170 }
171 
172 #endif // _CONNECTIVITY_KAB_STATEMENT_HXX_
173