LibreOffice Module connectivity (master) 1
OTools.hxx
Go to the documentation of this file.
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#pragma once
20
21#include <connectivity/odbc.hxx>
23#include <com/sun/star/sdbc/SQLException.hpp>
24#include <com/sun/star/util/Date.hpp>
25#include <com/sun/star/util/Time.hpp>
26#include <com/sun/star/util/DateTime.hpp>
27#include <osl/thread.h>
28#include <rtl/ustring.hxx>
29#include <com/sun/star/uno/Sequence.hxx>
30#include <rtl/textenc.h>
31
33{
34 AllocHandle = 1,
35 Connect = 2,
36 DriverConnect = 3,
37 BrowseConnect = 4,
38 DataSources = 5,
39 Drivers = 6,
40 GetInfo = 7,
41 GetFunctions = 8,
42 GetTypeInfo = 9,
43 SetConnectAttr = 10,
44 GetConnectAttr = 11,
45 SetEnvAttr = 12,
46 GetEnvAttr = 13,
47 SetStmtAttr = 14,
48 GetStmtAttr = 15,
49 Prepare = 16,
50 BindParameter = 17,
51 SetCursorName = 18,
52 Execute = 19,
53 ExecDirect = 20,
54 DescribeParam = 21,
55 NumParams = 22,
56 ParamData = 23,
57 PutData = 24,
58 RowCount = 25,
59 NumResultCols = 26,
60 DescribeCol = 27,
61 ColAttribute = 28,
62 BindCol = 29,
63 Fetch = 30,
64 FetchScroll = 31,
65 GetData = 32,
66 SetPos = 33,
67 BulkOperations = 34,
68 MoreResults = 35,
69 GetDiagRec = 36,
71 Columns = 38,
72 ForeignKeys = 39,
73 PrimaryKeys = 40,
75 Procedures = 42,
76 SpecialColumns = 43,
77 Statistics = 44,
78 TablePrivileges = 45,
79 Tables = 46,
80 FreeStmt = 47,
81 CloseCursor = 48,
82 Cancel = 49,
83 EndTran = 50,
84 Disconnect = 51,
85 FreeHandle = 52,
86 GetCursorName = 53,
87 NativeSql = 54,
88};
89
90namespace connectivity::odbc
91 {
92 class OConnection;
93
94 const sal_Int32 MAX_PUT_DATA_LENGTH = 2000;
95
97 {
98 public:
100 static void ThrowException( const OConnection* _pConnection,
101 SQLRETURN _rRetCode,
102 SQLHANDLE _pContext,
103 SQLSMALLINT _nHandleType,
104 const css::uno::Reference< css::uno::XInterface >& _xInterface,
105 bool _bNoFound=true);
106
109 static void GetInfo(OConnection const * _pConnection,
110 SQLHANDLE _aConnectionHandle,
111 SQLUSMALLINT _nInfo,
112 OUString &_rValue,
113 const css::uno::Reference< css::uno::XInterface >& _xInterface,
114 rtl_TextEncoding _nTextEncoding);
115
118 static void GetInfo(OConnection const * _pConnection,
119 SQLHANDLE _aConnectionHandle,
120 SQLUSMALLINT _nInfo,
121 sal_Int32 &_rValue,
122 const css::uno::Reference< css::uno::XInterface >& _xInterface);
123
126 static void GetInfo(OConnection const * _pConnection,
127 SQLHANDLE _aConnectionHandle,
128 SQLUSMALLINT _nInfo,
129 SQLUSMALLINT &_rValue,
130 const css::uno::Reference< css::uno::XInterface >& _xInterface);
131
134 static void GetInfo(OConnection const * _pConnection,
135 SQLHANDLE _aConnectionHandle,
136 SQLUSMALLINT _nInfo,
137 SQLUINTEGER &_rValue,
138 const css::uno::Reference< css::uno::XInterface >& _xInterface);
139
140 static sal_Int32 MapOdbcType2Jdbc(SQLSMALLINT _nType);
141 static SQLSMALLINT jdbcTypeToOdbc(sal_Int32 jdbcType);
142
143 static DATE_STRUCT DateToOdbcDate(const css::util::Date& x)
144 {
145 DATE_STRUCT aVal;
146 aVal.year = x.Year;
147 aVal.month = x.Month;
148 aVal.day = x.Day;
149 return aVal;
150 }
151 static TIME_STRUCT TimeToOdbcTime(const css::util::Time& x)
152 {
153 TIME_STRUCT aVal;
154 aVal.hour = x.Hours;
155 aVal.minute = x.Minutes;
156 aVal.second = x.Seconds;
157 return aVal;
158 }
159 static TIMESTAMP_STRUCT DateTimeToTimestamp(const css::util::DateTime& x)
160 {
161 TIMESTAMP_STRUCT aVal;
162 aVal.year = x.Year;
163 aVal.month = x.Month;
164 aVal.day = x.Day;
165 aVal.hour = x.Hours;
166 aVal.minute = x.Minutes;
167 aVal.second = x.Seconds;
168 aVal.fraction = x.NanoSeconds;
169 return aVal;
170 }
179 static void getBindTypes(bool _bUseWChar,
180 bool _bUseOldTimeDate,
181 SQLSMALLINT _nOdbcType,
182 SQLSMALLINT& fCType,
183 SQLSMALLINT& fSqlType);
184
187 static OUString getStringValue( OConnection const * _pConnection,
188 SQLHANDLE _aStatementHandle,
189 sal_Int32 columnIndex,
190 SQLSMALLINT _fSqlType,
191 bool &_bWasNull,
192 const css::uno::Reference< css::uno::XInterface >& _xInterface,
193 rtl_TextEncoding _nTextEncoding);
194
197 static css::uno::Sequence<sal_Int8> getBytesValue(const OConnection* _pConnection,
198 SQLHANDLE _aStatementHandle,
199 sal_Int32 columnIndex,
200 SQLSMALLINT _fSqlType,
201 bool &_bWasNull,
202 const css::uno::Reference< css::uno::XInterface >& _xInterface);
205 static void getValue( OConnection const * _pConnection,
206 SQLHANDLE _aStatementHandle,
207 sal_Int32 columnIndex,
208 SQLSMALLINT _nType,
209 bool &_bWasNull,
210 const css::uno::Reference< css::uno::XInterface >& _xInterface,
211 void* _pValue,
212 SQLLEN _nSize);
213
216 static void bindValue( OConnection const * _pConnection,
217 SQLHANDLE _aStatementHandle,
218 sal_Int32 columnIndex,
219 SQLSMALLINT _nType,
220 SQLSMALLINT _nMaxLen,
221 const void* _pValue,
222 void* _pData,
223 SQLLEN *pLen,
224 const css::uno::Reference< css::uno::XInterface >& _xInterface,
225 rtl_TextEncoding _nTextEncoding,
226 bool _bUseOldTimeDate);
227 };
228
231 template <class T> void getValue( const OConnection* _pConnection,
232 SQLHANDLE _aStatementHandle,
233 sal_Int32 columnIndex,
234 SQLSMALLINT _nType,
235 bool &_bWasNull,
236 const css::uno::Reference< css::uno::XInterface >& _xInterface,
237 T& _rValue)
238 {
239 OTools::getValue(_pConnection,_aStatementHandle,columnIndex,_nType,_bWasNull,_xInterface,&_rValue,sizeof _rValue);
240 }
241
242
243}
244
245/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define ThrowException(env, type, msg)
ODBC3SQLFunctionId
Definition: OTools.hxx:33
static void GetInfo(OConnection const *_pConnection, SQLHANDLE _aConnectionHandle, SQLUSMALLINT _nInfo, sal_Int32 &_rValue, const css::uno::Reference< css::uno::XInterface > &_xInterface)
static void getValue(OConnection const *_pConnection, SQLHANDLE _aStatementHandle, sal_Int32 columnIndex, SQLSMALLINT _nType, bool &_bWasNull, const css::uno::Reference< css::uno::XInterface > &_xInterface, void *_pValue, SQLLEN _nSize)
Definition: OTools.cxx:126
static void GetInfo(OConnection const *_pConnection, SQLHANDLE _aConnectionHandle, SQLUSMALLINT _nInfo, OUString &_rValue, const css::uno::Reference< css::uno::XInterface > &_xInterface, rtl_TextEncoding _nTextEncoding)
static void GetInfo(OConnection const *_pConnection, SQLHANDLE _aConnectionHandle, SQLUSMALLINT _nInfo, SQLUINTEGER &_rValue, const css::uno::Reference< css::uno::XInterface > &_xInterface)
static DATE_STRUCT DateToOdbcDate(const css::util::Date &x)
Definition: OTools.hxx:143
static TIME_STRUCT TimeToOdbcTime(const css::util::Time &x)
Definition: OTools.hxx:151
static void GetInfo(OConnection const *_pConnection, SQLHANDLE _aConnectionHandle, SQLUSMALLINT _nInfo, SQLUSMALLINT &_rValue, const css::uno::Reference< css::uno::XInterface > &_xInterface)
static TIMESTAMP_STRUCT DateTimeToTimestamp(const css::util::DateTime &x)
Definition: OTools.hxx:159
float x
void getValue(const OConnection *_pConnection, SQLHANDLE _aStatementHandle, sal_Int32 columnIndex, SQLSMALLINT _nType, bool &_bWasNull, const css::uno::Reference< css::uno::XInterface > &_xInterface, T &_rValue)
Definition: OTools.hxx:231
const sal_Int32 MAX_PUT_DATA_LENGTH
Definition: OTools.hxx:94
const ::avmedia::MediaItem * Execute(const SdrMarkView *pSdrView, SfxRequest const &rReq)
#define OOO_DLLPUBLIC_ODBCBASE