xref: /AOO41X/main/connectivity/source/drivers/macab/MacabStatement.hxx (revision 67e470dafe1997e73f56ff7ff4878983707e3e07)
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_MACAB_STATEMENT_HXX_
25 #define _CONNECTIVITY_MACAB_STATEMENT_HXX_
26 
27 #include "MacabConnection.hxx"
28 #include "MacabHeader.hxx"
29 #include <list>
30 #include "connectivity/sqliterator.hxx"
31 #ifndef _CONNECTIVITY_PARSE_SQLPARSE_HXX_
32 #include "connectivity/sqlparse.hxx"
33 #endif
34 #include <com/sun/star/sdbc/XStatement.hpp>
35 #include <com/sun/star/util/XCancellable.hpp>
36 #include <cppuhelper/compbase4.hxx>
37 #include <cppuhelper/implbase1.hxx>
38 #include <comphelper/proparrhlp.hxx>
39 
40 namespace connectivity
41 {
42     namespace macab
43     {
44         typedef ::cppu::WeakComponentImplHelper4<   ::com::sun::star::sdbc::XStatement,
45                                                     ::com::sun::star::sdbc::XWarningsSupplier,
46                                                     ::com::sun::star::util::XCancellable,
47                                                     ::com::sun::star::sdbc::XCloseable> MacabCommonStatement_BASE;
48 
49         //**************************************************************
50         // Class MacabCommonStatement
51         // is a base class for the normal statement and for the prepared statement
52         //**************************************************************
53         class MacabCommonStatement :    public comphelper::OBaseMutex,
54                         public  MacabCommonStatement_BASE,
55                         public  ::cppu::OPropertySetHelper,
56                         public  comphelper::OPropertyArrayUsageHelper<MacabCommonStatement>
57 
58         {
59             ::com::sun::star::sdbc::SQLWarning  m_aLastWarning;
60 
61         protected:
62             ::std::list< ::rtl::OUString>       m_aBatchList;
63             connectivity::OSQLParser            m_aParser;
64             connectivity::OSQLParseTreeIterator m_aSQLIterator;
65             connectivity::OSQLParseNode*        m_pParseTree;
66             MacabConnection*                        m_pConnection;  // The owning Connection object
67             MacabHeader*                            m_pHeader;  // The header of the address book on which to run queries (provided by m_pConnection)
68             ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet>    m_xResultSet;   // The last ResultSet created
69 
70 
71         protected:
72             class MacabCondition *analyseWhereClause(
73                 const OSQLParseNode *pParseNode) const throw(::com::sun::star::sdbc::SQLException);
74             class MacabOrder *analyseOrderByClause(
75                 const OSQLParseNode *pParseNode) const throw(::com::sun::star::sdbc::SQLException);
76             ::rtl::OUString getTableName( ) const;
77             void setMacabFields(class MacabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException);
78             void selectRecords(MacabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException);
79             void sortRecords(MacabResultSet *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 ~MacabCommonStatement();
101 
102         public:
103             ::cppu::OBroadcastHelper& rBHelper;
104 
105             MacabCommonStatement(MacabConnection *_pConnection);
106             using MacabCommonStatement_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
getOwnConnection() const151             inline MacabConnection* getOwnConnection() const { return m_pConnection; }
152         };
153 
154         //**************************************************************
155         // Class MacabStatement
156         //**************************************************************
157         typedef ::cppu::ImplInheritanceHelper1<
158                 MacabCommonStatement, ::com::sun::star::lang::XServiceInfo > MacabStatement_BASE;
159 
160         class MacabStatement : public MacabStatement_BASE
161         {
162         protected:
~MacabStatement()163             virtual ~MacabStatement() { }
164 
165         public:
166             MacabStatement(MacabConnection* _pConnection);
167             DECLARE_SERVICE_INFO();
168         };
169     }
170 }
171 
172 #endif // _CONNECTIVITY_MACAB_STATEMENT_HXX_
173