update dev300-m58
[ooovba.git] / connectivity / source / drivers / macab / MacabStatement.hxx
blob6d2966a60c82450314802566fba0528e36a32a91
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MacabStatement.hxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CONNECTIVITY_MACAB_STATEMENT_HXX_
32 #define _CONNECTIVITY_MACAB_STATEMENT_HXX_
34 #include "MacabConnection.hxx"
35 #include "MacabHeader.hxx"
36 #include <list>
37 #include "connectivity/sqliterator.hxx"
38 #ifndef _CONNECTIVITY_PARSE_SQLPARSE_HXX_
39 #include "connectivity/sqlparse.hxx"
40 #endif
41 #include <com/sun/star/sdbc/XStatement.hpp>
42 #include <com/sun/star/util/XCancellable.hpp>
43 #include <cppuhelper/compbase4.hxx>
44 #include <cppuhelper/implbase1.hxx>
45 #include <comphelper/proparrhlp.hxx>
47 namespace connectivity
49 namespace macab
51 typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::sdbc::XStatement,
52 ::com::sun::star::sdbc::XWarningsSupplier,
53 ::com::sun::star::util::XCancellable,
54 ::com::sun::star::sdbc::XCloseable> MacabCommonStatement_BASE;
56 //**************************************************************
57 // Class MacabCommonStatement
58 // is a base class for the normal statement and for the prepared statement
59 //**************************************************************
60 class MacabCommonStatement : public comphelper::OBaseMutex,
61 public MacabCommonStatement_BASE,
62 public ::cppu::OPropertySetHelper,
63 public comphelper::OPropertyArrayUsageHelper<MacabCommonStatement>
66 ::com::sun::star::sdbc::SQLWarning m_aLastWarning;
68 protected:
69 ::std::list< ::rtl::OUString> m_aBatchList;
70 connectivity::OSQLParser m_aParser;
71 connectivity::OSQLParseTreeIterator m_aSQLIterator;
72 connectivity::OSQLParseNode* m_pParseTree;
73 MacabConnection* m_pConnection; // The owning Connection object
74 MacabHeader* m_pHeader; // The header of the address book on which to run queries (provided by m_pConnection)
75 ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created
78 protected:
79 class MacabCondition *analyseWhereClause(
80 const OSQLParseNode *pParseNode) const throw(::com::sun::star::sdbc::SQLException);
81 class MacabOrder *analyseOrderByClause(
82 const OSQLParseNode *pParseNode) const throw(::com::sun::star::sdbc::SQLException);
83 ::rtl::OUString getTableName( ) const;
84 void setMacabFields(class MacabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException);
85 void selectRecords(MacabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException);
86 void sortRecords(MacabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException);
88 // OPropertyArrayUsageHelper
89 virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
91 // OPropertySetHelper
92 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
93 virtual sal_Bool SAL_CALL convertFastPropertyValue(
94 ::com::sun::star::uno::Any & rConvertedValue,
95 ::com::sun::star::uno::Any & rOldValue,
96 sal_Int32 nHandle,
97 const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::lang::IllegalArgumentException);
98 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
99 sal_Int32 nHandle,
100 const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
101 virtual void SAL_CALL getFastPropertyValue(
102 ::com::sun::star::uno::Any& rValue,
103 sal_Int32 nHandle) const;
105 virtual void resetParameters() const throw(::com::sun::star::sdbc::SQLException);
106 virtual void getNextParameter(::rtl::OUString &rParameter) const throw(::com::sun::star::sdbc::SQLException);
107 virtual ~MacabCommonStatement();
109 public:
110 ::cppu::OBroadcastHelper& rBHelper;
112 MacabCommonStatement(MacabConnection *_pConnection);
113 using MacabCommonStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
115 // OComponentHelper
116 virtual void SAL_CALL disposing();
118 // XInterface
119 virtual void SAL_CALL release() throw();
120 virtual void SAL_CALL acquire() throw();
121 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
122 const ::com::sun::star::uno::Type & rType
123 ) throw(::com::sun::star::uno::RuntimeException);
125 // XTypeProvider
126 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(
127 ) throw(::com::sun::star::uno::RuntimeException);
129 // XPropertySet
130 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(
131 ) throw(::com::sun::star::uno::RuntimeException);
133 // XStatement
134 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery(
135 const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
136 virtual sal_Int32 SAL_CALL executeUpdate(
137 const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
138 virtual sal_Bool SAL_CALL execute(
139 const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
140 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection(
141 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
143 // XWarningsSupplier
144 virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(
145 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
146 virtual void SAL_CALL clearWarnings(
147 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
149 // XCancellable
150 virtual void SAL_CALL cancel(
151 ) throw(::com::sun::star::uno::RuntimeException);
153 // XCloseable
154 virtual void SAL_CALL close(
155 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
157 // other methods
158 inline MacabConnection* getOwnConnection() const { return m_pConnection; }
161 //**************************************************************
162 // Class MacabStatement
163 //**************************************************************
164 typedef ::cppu::ImplInheritanceHelper1<
165 MacabCommonStatement, ::com::sun::star::lang::XServiceInfo > MacabStatement_BASE;
167 class MacabStatement : public MacabStatement_BASE
169 protected:
170 virtual ~MacabStatement() { }
172 public:
173 MacabStatement(MacabConnection* _pConnection);
174 DECLARE_SERVICE_INFO();
179 #endif // _CONNECTIVITY_MACAB_STATEMENT_HXX_