1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <com/sun/star/lang/XServiceInfo.hpp>
22 #include <com/sun/star/sdbc/XStatement.hpp>
23 #include <com/sun/star/sdbc/XConnection.hpp>
24 #include <com/sun/star/util/XCancellable.hpp>
25 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
26 #include <com/sun/star/sdbc/XCloseable.hpp>
27 #include <com/sun/star/sdbc/XMultipleResults.hpp>
28 #include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
29 #include <com/sun/star/sdbc/XBatchExecution.hpp>
30 #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
31 #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
32 #include <cppuhelper/propshlp.hxx>
33 #include <comphelper/proparrhlp.hxx>
34 #include <cppuhelper/basemutex.hxx>
35 #include <cppuhelper/implbase3.hxx>
36 #include <cppuhelper/compbase.hxx>
37 #include <unotools/weakref.hxx>
39 namespace dbaccess
{ class OConnection
; }
43 class OStatementBase
: public cppu::BaseMutex
,
44 public ::cppu::WeakComponentImplHelper
<>,
45 public ::cppu::OPropertySetHelper
,
46 public ::comphelper::OPropertyArrayUsageHelper
< OStatementBase
>,
47 public css::util::XCancellable
,
48 public css::sdbc::XWarningsSupplier
,
49 public css::sdbc::XPreparedBatchExecution
,
50 public css::sdbc::XMultipleResults
,
51 public css::sdbc::XCloseable
,
52 public css::sdbc::XGeneratedResultSet
55 unotools::WeakReference
<::dbaccess::OConnection
> m_xParent
;
56 ::osl::Mutex m_aCancelMutex
;
58 css::uno::WeakReferenceHelper m_aResultSet
;
59 css::uno::Reference
< css::beans::XPropertySet
> m_xAggregateAsSet
;
60 css::uno::Reference
< css::util::XCancellable
> m_xAggregateAsCancellable
;
62 bool m_bEscapeProcessing
;
64 virtual ~OStatementBase() override
;
67 OStatementBase(const rtl::Reference
< ::dbaccess::OConnection
> & _xConn
,
68 const css::uno::Reference
< css::uno::XInterface
> & _xStatement
);
71 // css::lang::XTypeProvider
72 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
74 // css::uno::XInterface
75 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
76 virtual void SAL_CALL
acquire() noexcept override
;
77 virtual void SAL_CALL
release() noexcept override
;
80 virtual void SAL_CALL
disposing() override
;
82 // css::beans::XPropertySet
83 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
85 // comphelper::OPropertyArrayUsageHelper
86 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const override
;
88 // cppu::OPropertySetHelper
89 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
91 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
92 css::uno::Any
& rConvertedValue
,
93 css::uno::Any
& rOldValue
,
95 const css::uno::Any
& rValue
) override
;
96 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
98 const css::uno::Any
& rValue
100 virtual void SAL_CALL
getFastPropertyValue( css::uno::Any
& rValue
, sal_Int32 nHandle
) const override
;
102 // css::sdbc::XWarningsSupplier
103 virtual css::uno::Any SAL_CALL
getWarnings( ) override
;
104 virtual void SAL_CALL
clearWarnings( ) override
;
106 // css::util::XCancellable
107 virtual void SAL_CALL
cancel( ) override
;
109 // css::sdbc::XCloseable
110 virtual void SAL_CALL
close( ) override
;
112 // css::sdbc::XMultipleResults
113 virtual css::uno::Reference
< css::sdbc::XResultSet
> SAL_CALL
getResultSet( ) override
;
114 virtual sal_Int32 SAL_CALL
getUpdateCount( ) override
;
115 virtual sal_Bool SAL_CALL
getMoreResults( ) override
;
117 // css::sdbc::XPreparedBatchExecution
118 virtual void SAL_CALL
addBatch( ) override
;
119 virtual void SAL_CALL
clearBatch( ) override
;
120 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
executeBatch( ) override
;
121 // css::sdbc::XGeneratedResultSet
122 virtual css::uno::Reference
< css::sdbc::XResultSet
> SAL_CALL
getGeneratedValues( ) override
;
125 void disposeResultSet();
128 using ::cppu::OPropertySetHelper::getFastPropertyValue
;
134 typedef ::cppu::ImplHelper3
< css::sdbc::XStatement
135 , css::lang::XServiceInfo
136 , css::sdbc::XBatchExecution
138 class OStatement
:public OStatementBase
139 ,public OStatement_IFACE
142 css::uno::Reference
< css::sdbc::XStatement
> m_xAggregateStatement
;
143 css::uno::Reference
< css::sdb::XSingleSelectQueryComposer
> m_xComposer
;
144 bool m_bAttemptedComposerCreation
;
147 OStatement(const rtl::Reference
< ::dbaccess::OConnection
> & _xConn
,
148 const css::uno::Reference
< css::uno::XInterface
> & _xStatement
);
151 DECLARE_XTYPEPROVIDER()
153 // css::lang::XServiceInfo
154 virtual OUString SAL_CALL
getImplementationName( ) override
;
155 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
156 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
158 // css::sdbc::XStatement
159 virtual css::uno::Reference
< css::sdbc::XResultSet
> SAL_CALL
executeQuery( const OUString
& sql
) override
;
160 virtual sal_Int32 SAL_CALL
executeUpdate( const OUString
& sql
) override
;
161 virtual sal_Bool SAL_CALL
execute( const OUString
& sql
) override
;
162 virtual css::uno::Reference
< css::sdbc::XConnection
> SAL_CALL
getConnection( ) override
;
165 virtual void SAL_CALL
disposing() override
;
168 virtual void SAL_CALL
addBatch( const OUString
& sql
) override
;
169 virtual void SAL_CALL
clearBatch( ) override
;
170 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
executeBatch( ) override
;
172 using OStatementBase::addBatch
;
175 /** does escape processing for the given SQL command, if the our EscapeProcessing
178 OUString
impl_doEscapeProcessing_nothrow( const OUString
& _rSQL
) const;
179 bool impl_ensureComposer_nothrow() const;
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */