1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ 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 20 #pragma once 21 22 #include <sal/config.h> 23 24 #include <string_view> 25 26 #include "Connection.hxx" 27 #include "SubComponent.hxx" 28 29 #include <ibase.h> 30 31 #include <cppuhelper/compbase.hxx> 32 #include <rtl/ref.hxx> 33 34 #include <com/sun/star/sdbc/XCloseable.hpp> 35 #include <com/sun/star/sdbc/XMultipleResults.hpp> 36 #include <com/sun/star/sdbc/XWarningsSupplier.hpp> 37 #include <com/sun/star/util/XCancellable.hpp> 38 39 namespace connectivity::firebird 40 { 41 42 typedef ::cppu::WeakComponentImplHelper< css::sdbc::XWarningsSupplier, 43 css::util::XCancellable, 44 css::sdbc::XCloseable, 45 css::sdbc::XMultipleResults> OStatementCommonBase_Base; 46 47 class OStatementCommonBase : public OStatementCommonBase_Base, 48 public ::cppu::OPropertySetHelper, 49 public OPropertyArrayUsageHelper<OStatementCommonBase> 50 51 { 52 protected: 53 ::osl::Mutex m_aMutex; 54 55 css::uno::Reference< css::sdbc::XResultSet> m_xResultSet; // The last ResultSet created 56 // for this Statement 57 58 ::rtl::Reference<Connection> m_pConnection; 59 60 ISC_STATUS_ARRAY m_statusVector; 61 isc_stmt_handle m_aStatementHandle; 62 63 protected: 64 virtual void disposeResultSet(); 65 /// @throws css::sdbc::SQLException 66 void freeStatementHandle(); 67 68 // OPropertyArrayUsageHelper 69 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override; 70 // OPropertySetHelper 71 using OPropertySetHelper::getFastPropertyValue; 72 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; 73 virtual sal_Bool SAL_CALL convertFastPropertyValue( 74 css::uno::Any & rConvertedValue, 75 css::uno::Any & rOldValue, 76 sal_Int32 nHandle, 77 const css::uno::Any& rValue ) override; 78 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 79 sal_Int32 nHandle, 80 const css::uno::Any& rValue) override; 81 virtual void SAL_CALL getFastPropertyValue( 82 css::uno::Any& rValue, 83 sal_Int32 nHandle) const override; 84 virtual ~OStatementCommonBase() override; 85 86 /// @throws css::sdbc::SQLException 87 void prepareAndDescribeStatement(std::u16string_view sqlIn, XSQLDA*& pOutSqlda); 88 89 /// @throws css::sdbc::SQLException 90 short getSqlInfoItem(char aInfoItem); 91 /// @throws css::sdbc::SQLException 92 bool isDDLStatement(); 93 /// @throws css::sdbc::SQLException 94 sal_Int32 getStatementChangeCount(); 95 96 public: 97 98 explicit OStatementCommonBase(Connection* _pConnection); 99 using OStatementCommonBase_Base::operator css::uno::Reference< css::uno::XInterface >; 100 101 // OComponentHelper disposing()102 virtual void SAL_CALL disposing() override { 103 disposeResultSet(); 104 OStatementCommonBase_Base::disposing(); 105 } 106 // XInterface 107 virtual void SAL_CALL release() noexcept override; 108 virtual void SAL_CALL acquire() noexcept override; 109 // XInterface 110 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; 111 //XTypeProvider 112 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; 113 114 // XPropertySet 115 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; 116 117 // XWarningsSupplier - UNSUPPORTED 118 virtual css::uno::Any SAL_CALL getWarnings( ) override; 119 virtual void SAL_CALL clearWarnings( ) override; 120 // XMultipleResults - UNSUPPORTED 121 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet( ) override; 122 virtual sal_Int32 SAL_CALL getUpdateCount( ) override; 123 virtual sal_Bool SAL_CALL getMoreResults( ) override; 124 125 // XCancellable 126 virtual void SAL_CALL cancel( ) override; 127 // XCloseable 128 virtual void SAL_CALL close( ) override; 129 130 }; 131 132 } 133 134 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ 135
