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