Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : : #ifndef _DBA_COREAPI_STATEMENT_HXX_
20 : : #define _DBA_COREAPI_STATEMENT_HXX_
21 : :
22 : : #include <com/sun/star/lang/XServiceInfo.hpp>
23 : : #include <com/sun/star/sdbc/XStatement.hpp>
24 : : #include <com/sun/star/sdbc/XConnection.hpp>
25 : : #include <com/sun/star/util/XCancellable.hpp>
26 : : #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
27 : : #include <com/sun/star/sdbc/XCloseable.hpp>
28 : : #include <com/sun/star/sdbc/XMultipleResults.hpp>
29 : : #include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
30 : : #include <com/sun/star/sdbc/XBatchExecution.hpp>
31 : : #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
32 : : #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
33 : : #include <cppuhelper/propshlp.hxx>
34 : : #include <comphelper/proparrhlp.hxx>
35 : : #include "apitools.hxx"
36 : : #include <comphelper/broadcasthelper.hxx>
37 : :
38 : : #include <cppuhelper/implbase3.hxx>
39 : :
40 : : //************************************************************
41 : : // OStatementBase
42 : : //************************************************************
43 : : class OStatementBase : public comphelper::OBaseMutex,
44 : : public OSubComponent,
45 : : public ::cppu::OPropertySetHelper,
46 : : public ::comphelper::OPropertyArrayUsageHelper < OStatementBase >,
47 : : public ::com::sun::star::util::XCancellable,
48 : : public ::com::sun::star::sdbc::XWarningsSupplier,
49 : : public ::com::sun::star::sdbc::XPreparedBatchExecution,
50 : : public ::com::sun::star::sdbc::XMultipleResults,
51 : : public ::com::sun::star::sdbc::XCloseable,
52 : : public ::com::sun::star::sdbc::XGeneratedResultSet
53 : : {
54 : : protected:
55 : : ::osl::Mutex m_aCancelMutex;
56 : :
57 : : ::com::sun::star::uno::WeakReferenceHelper m_aResultSet;
58 : : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xAggregateAsSet;
59 : : ::com::sun::star::uno::Reference< ::com::sun::star::util::XCancellable > m_xAggregateAsCancellable;
60 : : sal_Bool m_bUseBookmarks;
61 : : sal_Bool m_bEscapeProcessing;
62 : :
63 : : virtual ~OStatementBase();
64 : :
65 : : public:
66 : : OStatementBase(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > & _xConn,
67 : : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & _xStatement);
68 : :
69 : :
70 : : // ::com::sun::star::lang::XTypeProvider
71 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
72 : :
73 : : // ::com::sun::star::uno::XInterface
74 : : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException);
75 : : virtual void SAL_CALL acquire() throw();
76 : : virtual void SAL_CALL release() throw();
77 : :
78 : : // OComponentHelper
79 : : virtual void SAL_CALL disposing(void);
80 : :
81 : : // com::sun::star::beans::XPropertySet
82 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
83 : :
84 : : // comphelper::OPropertyArrayUsageHelper
85 : : virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
86 : :
87 : : // cppu::OPropertySetHelper
88 : : virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
89 : :
90 : : virtual sal_Bool SAL_CALL convertFastPropertyValue(
91 : : ::com::sun::star::uno::Any & rConvertedValue,
92 : : ::com::sun::star::uno::Any & rOldValue,
93 : : sal_Int32 nHandle,
94 : : const ::com::sun::star::uno::Any& rValue )
95 : : throw (::com::sun::star::lang::IllegalArgumentException);
96 : : virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
97 : : sal_Int32 nHandle,
98 : : const ::com::sun::star::uno::Any& rValue
99 : : )
100 : : throw (::com::sun::star::uno::Exception);
101 : : virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
102 : :
103 : : // ::com::sun::star::sdbc::XWarningsSupplier
104 : : virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
105 : : virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
106 : :
107 : : // ::com::sun::star::util::XCancellable
108 : : virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException);
109 : :
110 : : // ::com::sun::star::sdbc::XCloseable
111 : : virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
112 : :
113 : : // ::com::sun::star::sdbc::XMultipleResults
114 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
115 : : virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
116 : : virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
117 : :
118 : : // ::com::sun::star::sdbc::XPreparedBatchExecution
119 : : virtual void SAL_CALL addBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
120 : : virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
121 : : virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
122 : : // ::com::sun::star::sdbc::XGeneratedResultSet
123 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getGeneratedValues( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
124 : :
125 : : // Helper
126 : : void disposeResultSet();
127 : :
128 : : protected:
129 : : using ::cppu::OPropertySetHelper::getFastPropertyValue;
130 : : };
131 : :
132 : : //************************************************************
133 : : // OStatement
134 : : //************************************************************
135 : : typedef ::cppu::ImplHelper3 < ::com::sun::star::sdbc::XStatement
136 : : , ::com::sun::star::lang::XServiceInfo
137 : : , ::com::sun::star::sdbc::XBatchExecution
138 : : > OStatement_IFACE;
139 [ - + ]: 44 : class OStatement :public OStatementBase
140 : : ,public OStatement_IFACE
141 : : {
142 : : private:
143 : : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > m_xAggregateStatement;
144 : : ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > m_xComposer;
145 : : bool m_bAttemptedComposerCreation;
146 : :
147 : : public:
148 : : OStatement(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > & _xConn,
149 : : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & _xStatement);
150 : :
151 : : DECLARE_XINTERFACE()
152 : : DECLARE_XTYPEPROVIDER()
153 : :
154 : : // ::com::sun::star::lang::XServiceInfo
155 : : virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
156 : : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
157 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
158 : :
159 : : // ::com::sun::star::sdbc::XStatement
160 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
161 : : virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
162 : : virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
163 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
164 : :
165 : : // OComponentHelper
166 : : virtual void SAL_CALL disposing();
167 : :
168 : : // XBatchExecution
169 : : virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
170 : : virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
171 : : virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
172 : :
173 : : using OStatementBase::addBatch;
174 : :
175 : : private:
176 : : /** does escape processing for the given SQL command, if the our EscapeProcessing
177 : : property allows so.
178 : : */
179 : : ::rtl::OUString impl_doEscapeProcessing_nothrow( const ::rtl::OUString& _rSQL ) const;
180 : : bool impl_ensureComposer_nothrow() const;
181 : : };
182 : :
183 : : #endif // _DBA_COREAPI_STATEMENT_HXX_
184 : :
185 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|