tdf#150789 - FILEOPEN PPTX: fix text in SmartArt vertically off
[LibreOffice.git] / connectivity / source / drivers / firebird / ResultSet.hxx
blob046be37c567a12f4479d952840434f479a517a25
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.
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 "Connection.hxx"
24 #include <ibase.h>
26 #include <connectivity/FValue.hxx>
27 #include <cppuhelper/compbase.hxx>
28 #include <comphelper/proparrhlp.hxx>
29 #include <comphelper/propertycontainer.hxx>
31 #include <com/sun/star/util/XCancellable.hpp>
32 #include <com/sun/star/sdbc/XCloseable.hpp>
33 #include <com/sun/star/sdbc/XColumnLocate.hpp>
34 #include <com/sun/star/sdbc/XResultSet.hpp>
35 #include <com/sun/star/sdbc/XRow.hpp>
36 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
38 #include <type_traits>
40 namespace connectivity::firebird
42 class OResultSetMetaData;
44 ** OResultSet
46 typedef ::cppu::WeakComponentImplHelper< css::sdbc::XResultSet,
47 css::sdbc::XRow,
48 css::sdbc::XResultSetMetaDataSupplier,
49 css::util::XCancellable,
50 css::sdbc::XCloseable,
51 css::sdbc::XColumnLocate,
52 css::lang::XServiceInfo> OResultSet_BASE;
54 /**
55 * This ResultSet does not deal with the management of the SQLDA
56 * it is supplied with. The owner must manage its SQLDA appropriately
57 * and ensure that the ResultSet is destroyed before disposing of the
58 * SQLDA.
60 class OResultSet: public OResultSet_BASE,
61 public ::comphelper::OPropertyContainer,
62 public ::comphelper::OPropertyArrayUsageHelper<OResultSet>
64 private:
65 bool m_bIsBookmarkable;
66 sal_Int32 m_nFetchSize;
67 sal_Int32 m_nResultSetType;
68 sal_Int32 m_nFetchDirection;
69 sal_Int32 m_nResultSetConcurrency;
71 protected:
72 // Connection kept alive by m_xStatement
73 Connection* m_pConnection;
74 ::osl::Mutex& m_rMutex;
75 const css::uno::Reference< css::uno::XInterface >& m_xStatement;
77 rtl::Reference<OResultSetMetaData> m_xMetaData;
79 XSQLDA* m_pSqlda;
80 isc_stmt_handle m_statementHandle;
82 bool m_bWasNull;
83 // Row numbering starts with 0 for "in front of first row"
84 sal_Int32 m_currentRow;
85 bool m_bIsAfterLastRow;
87 const sal_Int32 m_fieldCount;
88 ISC_STATUS_ARRAY m_statusVector;
90 bool isNull(const sal_Int32 nColumnIndex);
92 template <typename T> requires std::is_integral_v<T>
93 OUString makeNumericString(const sal_Int32 nColumnIndex);
95 template <typename T> T retrieveValue(const sal_Int32 nColumnIndex,
96 const ISC_SHORT nType);
98 template <typename T> T safelyRetrieveValue(
99 const sal_Int32 nColumnIndex,
100 const ISC_SHORT nType = 0);
102 // OIdPropertyArrayUsageHelper
103 virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const override;
104 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
106 /// @throws css::sdbc::SQLException
107 /// @throws css::uno::RuntimeException
108 void checkColumnIndex( sal_Int32 index );
109 /// @throws css::sdbc::SQLException
110 /// @throws css::uno::RuntimeException
111 void checkRowIndex();
113 // you can't delete objects of this type
114 virtual ~OResultSet() override;
115 public:
116 DECLARE_SERVICE_INFO();
118 OResultSet(Connection* pConnection,
119 ::osl::Mutex& rMutex,
120 const css::uno::Reference< css::uno::XInterface >& xStatement,
121 isc_stmt_handle aStatementHandle,
122 XSQLDA* aSqlda
125 // XInterface
126 virtual css::uno::Any SAL_CALL queryInterface(
127 const css::uno::Type& rType) override;
128 virtual void SAL_CALL acquire() noexcept override;
129 virtual void SAL_CALL release() noexcept override;
130 //XTypeProvider
131 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
132 // XPropertySet
133 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
134 // XResultSet
135 virtual sal_Bool SAL_CALL next( ) override;
136 virtual sal_Bool SAL_CALL isBeforeFirst( ) override;
137 virtual sal_Bool SAL_CALL isAfterLast( ) override;
138 virtual sal_Bool SAL_CALL isFirst( ) override;
139 virtual sal_Bool SAL_CALL isLast( ) override;
140 virtual void SAL_CALL beforeFirst( ) override;
141 virtual void SAL_CALL afterLast( ) override;
142 virtual sal_Bool SAL_CALL first( ) override;
143 virtual sal_Bool SAL_CALL last( ) override;
144 virtual sal_Int32 SAL_CALL getRow( ) override;
145 virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) override;
146 virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) override;
147 virtual sal_Bool SAL_CALL previous( ) override;
148 virtual void SAL_CALL refreshRow( ) override;
149 virtual sal_Bool SAL_CALL rowUpdated( ) override;
150 virtual sal_Bool SAL_CALL rowInserted( ) override;
151 virtual sal_Bool SAL_CALL rowDeleted( ) override;
152 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement( ) override;
153 // XRow
154 virtual sal_Bool SAL_CALL wasNull( ) override;
155 virtual OUString SAL_CALL getString( sal_Int32 columnIndex ) override;
156 virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) override;
157 virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) override;
158 virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) override;
159 virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) override;
160 virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) override;
161 virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) override;
162 virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) override;
163 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) override;
164 virtual css::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) override;
165 virtual css::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) override;
166 virtual css::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) override;
167 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) override;
168 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) override;
169 virtual css::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess >& typeMap ) override;
170 virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) override;
171 virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) override;
172 virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) override;
173 virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) override;
174 // XResultSetMetaDataSupplier
175 virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) override;
176 // XCancellable
177 virtual void SAL_CALL cancel( ) override;
178 // XCloseable
179 virtual void SAL_CALL close( ) override;
180 // XWarningsSupplier
182 // XColumnLocate
183 virtual sal_Int32 SAL_CALL findColumn(const OUString& columnName) override;
187 // Specialisations have to be in the namespace and can't be within the class.
188 template <> css::util::Date
189 OResultSet::retrieveValue(
190 const sal_Int32 nColumnIndex,
191 const ISC_SHORT nType);
192 template <> ::connectivity::ORowSetValue
193 OResultSet::retrieveValue(
194 const sal_Int32 nColumnIndex,
195 const ISC_SHORT nType);
196 template <> css::util::Time
197 OResultSet::retrieveValue(
198 const sal_Int32 nColumnIndex,
199 const ISC_SHORT nType);
200 template <> css::util::DateTime
201 OResultSet::retrieveValue(
202 const sal_Int32 nColumnIndex,
203 const ISC_SHORT nType);
204 template <> ISC_QUAD*
205 OResultSet::retrieveValue(
206 const sal_Int32 nColumnIndex,
207 const ISC_SHORT nType);
208 template <> OUString
209 OResultSet::retrieveValue(
210 const sal_Int32 nColumnIndex,
211 const ISC_SHORT nType);
212 template <> ISC_QUAD*
213 OResultSet::retrieveValue(
214 const sal_Int32 nColumnIndex,
215 const ISC_SHORT nType);
219 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */