tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / connectivity / source / inc / ado / AStatement.hxx
blobb8e3e1a6ff9c1406d4e0ec363ed5348bc5c610ba
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #pragma once
22 #include <com/sun/star/sdbc/XStatement.hpp>
23 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
24 #include <com/sun/star/sdbc/XMultipleResults.hpp>
25 #include <com/sun/star/sdbc/XBatchExecution.hpp>
26 #include <com/sun/star/sdbc/XCloseable.hpp>
27 #include <com/sun/star/sdbc/SQLWarning.hpp>
28 #include <com/sun/star/util/XCancellable.hpp>
29 #include <cppuhelper/compbase.hxx>
30 #include <cppuhelper/basemutex.hxx>
31 #include <comphelper/proparrhlp.hxx>
32 #include <unotools/weakref.hxx>
33 #include <ado/AConnection.hxx>
34 #include <string_view>
35 #include <vector>
36 #include <ado/Awrapado.hxx>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
39 namespace connectivity::ado
41 typedef ::cppu::WeakComponentImplHelper< css::sdbc::XStatement,
42 css::sdbc::XWarningsSupplier,
43 css::util::XCancellable,
44 css::sdbc::XCloseable,
45 css::sdbc::XMultipleResults> OStatement_BASE;
48 //************ Class: java.sql.Statement
50 class OStatement_Base : public cppu::BaseMutex,
51 public OStatement_BASE,
52 public ::cppu::OPropertySetHelper,
53 public ::comphelper::OPropertyArrayUsageHelper<OStatement_Base>
56 friend class OResultSet;
58 css::sdbc::SQLWarning m_aLastWarning;
60 protected:
61 std::vector< OUString> m_aBatchVector;
63 unotools::WeakReference<OResultSet> m_xResultSet; // The last ResultSet created
64 // for this Statement
66 OConnection* m_pConnection;// The owning Connection object
67 WpADOCommand m_Command;
68 WpADORecordset m_RecordSet;
69 OLEVariant m_RecordsAffected;
70 OLEVariant m_Parameters;
71 std::vector<connectivity::OTypeInfo> m_aTypeInfo; // Hashtable containing an entry
72 // for each row returned by
73 // DatabaseMetaData.getTypeInfo.
74 long m_nMaxRows;
75 sal_Int32 m_nFetchSize;
76 LockTypeEnum m_eLockType;
77 CursorTypeEnum m_eCursorType;
79 using OStatement_BASE::rBHelper;
80 private:
81 /// @throws css::sdbc::SQLException
82 /// @throws css::uno::RuntimeException
83 sal_Int32 getQueryTimeOut() const;
84 /// @throws css::sdbc::SQLException
85 /// @throws css::uno::RuntimeException
86 static sal_Int32 getMaxFieldSize();
87 /// @throws css::sdbc::SQLException
88 /// @throws css::uno::RuntimeException
89 sal_Int32 getMaxRows() const;
90 /// @throws css::sdbc::SQLException
91 /// @throws css::uno::RuntimeException
92 sal_Int32 getResultSetConcurrency() const;
93 /// @throws css::sdbc::SQLException
94 /// @throws css::uno::RuntimeException
95 sal_Int32 getResultSetType() const;
96 /// @throws css::sdbc::SQLException
97 /// @throws css::uno::RuntimeException
98 static sal_Int32 getFetchDirection();
99 /// @throws css::sdbc::SQLException
100 /// @throws css::uno::RuntimeException
101 sal_Int32 getFetchSize() const;
102 /// @throws css::sdbc::SQLException
103 /// @throws css::uno::RuntimeException
104 OUString getCursorName() const;
106 /// @throws css::sdbc::SQLException
107 /// @throws css::uno::RuntimeException
108 void setQueryTimeOut(sal_Int32 _par0);
109 /// @throws css::sdbc::SQLException
110 /// @throws css::uno::RuntimeException
111 void setMaxFieldSize(sal_Int32 _par0);
112 /// @throws css::sdbc::SQLException
113 /// @throws css::uno::RuntimeException
114 void setMaxRows(sal_Int32 _par0);
115 /// @throws css::sdbc::SQLException
116 /// @throws css::uno::RuntimeException
117 void setResultSetConcurrency(sal_Int32 _par0);
118 /// @throws css::sdbc::SQLException
119 /// @throws css::uno::RuntimeException
120 void setResultSetType(sal_Int32 _par0);
121 /// @throws css::sdbc::SQLException
122 /// @throws css::uno::RuntimeException
123 void setFetchDirection(sal_Int32 _par0);
124 /// @throws css::sdbc::SQLException
125 /// @throws css::uno::RuntimeException
126 void setFetchSize(sal_Int32 _par0);
127 /// @throws css::sdbc::SQLException
128 /// @throws css::uno::RuntimeException
129 void setCursorName(std::u16string_view _par0);
131 protected:
133 void assignRecordSet( ADORecordset* _pRS );
135 /// @throws css::sdbc::SQLException
136 void reset ();
137 /// @throws css::sdbc::SQLException
138 void clearMyResultSet ();
139 /// @throws css::sdbc::SQLException
140 void setWarning (const css::sdbc::SQLWarning &ex);
141 /// @throws css::sdbc::SQLException
142 sal_Int32 getRowCount ();
143 sal_Int32 getPrecision ( sal_Int32 sqlType);
145 void disposeResultSet();
147 // OPropertyArrayUsageHelper
148 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
149 // OPropertySetHelper
150 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
151 virtual sal_Bool SAL_CALL convertFastPropertyValue(
152 css::uno::Any & rConvertedValue,
153 css::uno::Any & rOldValue,
154 sal_Int32 nHandle,
155 const css::uno::Any& rValue ) override;
156 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
157 sal_Int32 nHandle,
158 const css::uno::Any& rValue
159 ) override;
160 virtual void SAL_CALL getFastPropertyValue(
161 css::uno::Any& rValue,
162 sal_Int32 nHandle
163 ) const override;
164 public:
165 OStatement_Base(OConnection* _pConnection );
167 using OStatement_BASE::operator css::uno::Reference< css::uno::XInterface >;
168 // OComponentHelper
169 virtual void SAL_CALL disposing() override;
170 // XInterface
171 virtual void SAL_CALL acquire() noexcept override;
172 virtual void SAL_CALL release() noexcept override;
173 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
174 //XTypeProvider
175 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
177 // XPropertySet
178 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
179 // XStatement
180 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery( const OUString& sql ) override;
181 virtual sal_Int32 SAL_CALL executeUpdate( const OUString& sql ) override;
182 virtual sal_Bool SAL_CALL execute( const OUString& sql ) override;
183 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( ) override;
184 // XWarningsSupplier
185 virtual css::uno::Any SAL_CALL getWarnings( ) override;
186 virtual void SAL_CALL clearWarnings( ) override;
187 // XCancellable
188 virtual void SAL_CALL cancel( ) override;
189 // XCloseable
190 virtual void SAL_CALL close( ) override;
191 // XMultipleResults
192 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet( ) override;
193 virtual sal_Int32 SAL_CALL getUpdateCount( ) override;
194 virtual sal_Bool SAL_CALL getMoreResults( ) override;
197 class OStatement : public OStatement_Base,
198 public css::sdbc::XBatchExecution,
199 public css::lang::XServiceInfo
201 public:
202 // a Constructor, that is needed for when Returning the Object is needed:
203 OStatement( OConnection* _pConnection) : OStatement_Base( _pConnection){};
204 ~OStatement() override;
206 DECLARE_SERVICE_INFO();
208 virtual void SAL_CALL acquire() noexcept override;
209 virtual void SAL_CALL release() noexcept override;
210 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
211 // XBatchExecution
212 virtual void SAL_CALL addBatch( const OUString& sql ) override;
213 virtual void SAL_CALL clearBatch( ) override;
214 virtual css::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) override;
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */